Skip to content

Commit 5b095e5

Browse files
authored
fix: use "T" separator in time format placeholder to accomodate Safari (#3622)
1 parent adfd0e0 commit 5b095e5

File tree

3 files changed

+46
-2
lines changed

3 files changed

+46
-2
lines changed

src/utils/datetime/formatters.test.ts

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,50 @@ describe('the DateTime formatter', () => {
419419
date.toISOString()
420420
}).not.toThrow()
421421
})
422+
423+
it('can use the T as a separator', () => {
424+
let convertedDateString = convertDateToRFC3339(
425+
new Date('2022-01-18T17:30:00Z'),
426+
'Local'
427+
)
428+
let date = new Date(convertedDateString)
429+
expect(date.toDateString()).not.toEqual('Invalid Date')
430+
expect(() => {
431+
date.toISOString()
432+
}).not.toThrow()
433+
434+
convertedDateString = convertDateToRFC3339(
435+
new Date('2022-01-19T01:30:00-0800'),
436+
'UTC'
437+
)
438+
date = new Date(convertedDateString)
439+
expect(date.toDateString()).not.toEqual('Invalid Date')
440+
expect(() => {
441+
date.toISOString()
442+
}).not.toThrow()
443+
})
444+
445+
it('can use space as a separator', () => {
446+
let convertedDateString = convertDateToRFC3339(
447+
new Date('2022-01-18 17:30:00Z'),
448+
'Local'
449+
)
450+
let date = new Date(convertedDateString)
451+
expect(date.toDateString()).not.toEqual('Invalid Date')
452+
expect(() => {
453+
date.toISOString()
454+
}).not.toThrow()
455+
456+
convertedDateString = convertDateToRFC3339(
457+
new Date('2022-01-19 01:30:00-0800'),
458+
'UTC'
459+
)
460+
date = new Date(convertedDateString)
461+
expect(date.toDateString()).not.toEqual('Invalid Date')
462+
expect(() => {
463+
date.toISOString()
464+
}).not.toThrow()
465+
})
422466
})
423467
})
424468

src/utils/datetime/formatters.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -804,7 +804,7 @@ export const convertDateToRFC3339 = (date: Date, timeZone: string): string => {
804804
const localTime = timeStringParsed[0]
805805
const utcOffset = timeStringParsed[1].replace('GMT', '')
806806

807-
return `${year}-${month}-${dayOfMonth} ${localTime}${utcOffset}`
807+
return `${year}-${month}-${dayOfMonth}T${localTime}${utcOffset}`
808808
}
809809
return date.toISOString()
810810
}

src/visualization/components/internal/TimeTickInput.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ export const TimeTickInput: FC<TimeTickInputProps> = props => {
6767
tickPropertyName,
6868
tickOptions,
6969
initialTickOptionValue,
70-
dateFormatPlaceholder = 'RFC 3339 or YYYY-MM-DD HH:MM:SSZ',
70+
dateFormatPlaceholder = 'RFC 3339 or YYYY-MM-DDTHH:mm:ssZ',
7171
update,
7272
} = props
7373

0 commit comments

Comments
 (0)