diff --git a/packages/core/src/utils/dateToLocaleISOString.newfoundland.spec.js b/packages/core/src/utils/dateToLocaleISOString.newfoundland.spec.js index a2f1132c7a..0f783d687a 100644 --- a/packages/core/src/utils/dateToLocaleISOString.newfoundland.spec.js +++ b/packages/core/src/utils/dateToLocaleISOString.newfoundland.spec.js @@ -10,5 +10,5 @@ test('formatting a time in Cananda, Newfoundland timezone', () => { const date = new Date(Date.UTC(2000, 0, 1, 0, 12, 34, 567)); const actual = dateToLocaleISOString(date); - expect(actual).toMatchInlineSnapshot(`"2000-01-01T09:12:34.567-03:30"`); + expect(actual).toMatchInlineSnapshot(`"1999-12-31T20:42:34.567-03:30"`); }); diff --git a/packages/core/src/utils/dateToLocaleISOString.ts b/packages/core/src/utils/dateToLocaleISOString.ts index 25589d7e8e..3d3c7f16f0 100644 --- a/packages/core/src/utils/dateToLocaleISOString.ts +++ b/packages/core/src/utils/dateToLocaleISOString.ts @@ -45,9 +45,11 @@ export default function dateToLocaleISOString(date: Date): string { // "yyyy-MM-DDTHH:mm:ss.fff+08:00" for GMT+08 // "yyyy-MM-DDTHH:mm:ss.fffZ" for UTC + const absoluteTimezoneOffset = ~~Math.abs(timezoneOffset); + return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())}T${pad(date.getHours())}:${pad( date.getMinutes() )}:${pad(date.getSeconds())}.${pad(date.getMilliseconds(), 3)}${ - timezoneOffset ? `${timezoneSign}${pad(~~(Math.abs(timezoneOffset) / 60))}:${pad(timezoneOffset % 60)}` : 'Z' + timezoneOffset ? `${timezoneSign}${pad(~~(absoluteTimezoneOffset / 60))}:${pad(absoluteTimezoneOffset % 60)}` : 'Z' }`; }