99import type { ColumnDefinition } from '@/lib/table/types'
1010
1111const NUMERIC_VALUE_PATTERN = / ^ - ? \d + (?: \. \d + ) ? $ /
12- const EXPLICIT_OFFSET_PATTERN = / (?: Z | [ + - ] \d { 2 } : ? \d { 2 } ) $ / i
12+ const ISO_DATE_PREFIX_PATTERN = / ^ ( \d { 4 } - \d { 2 } - \d { 2 } ) (?: $ | [ T ] ) / i
1313
1414function isRepresentableEpochSeconds ( value : number ) : boolean {
1515 return Number . isSafeInteger ( value ) && ! Number . isNaN ( new Date ( value * 1000 ) . getTime ( ) )
@@ -36,19 +36,14 @@ export function parseTtlEpochSeconds(
3636 return isRepresentableEpochSeconds ( numeric ) ? numeric : null
3737 }
3838
39- if ( EXPLICIT_OFFSET_PATTERN . test ( trimmed ) ) {
40- const milliseconds = Date . parse ( trimmed )
41- if ( Number . isNaN ( milliseconds ) ) return null
42- const seconds = Math . floor ( milliseconds / 1000 )
43- return isRepresentableEpochSeconds ( seconds ) ? seconds : null
44- }
45-
4639 const normalized = normalizeDateCellValue ( trimmed , options )
4740 if ( normalized === null ) return null
4841 const instant = / ^ \d { 4 } - \d { 2 } - \d { 2 } $ / . test ( normalized )
4942 ? normalizeDateCellValue ( `${ normalized } T00:00:00` , options )
5043 : normalized
5144 if ( instant === null ) return null
45+ const inputIsoDate = trimmed . match ( ISO_DATE_PREFIX_PATTERN ) ?. [ 1 ]
46+ if ( inputIsoDate && instant . slice ( 0 , 10 ) !== inputIsoDate ) return null
5247 const milliseconds = Date . parse ( instant )
5348 if ( Number . isNaN ( milliseconds ) ) return null
5449 const seconds = Math . floor ( milliseconds / 1000 )
0 commit comments