diff --git a/CHANGELOG.md b/CHANGELOG.md index af40717856..36b66eb98c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,6 +30,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Fixes [#5050](https://github.com/microsoft/BotFramework-WebChat/issues/5050). Fixed focus should not blur briefly after tapping on a suggested action, by [@compulim](https://github.com/compulim), in PR [#5097](https://github.com/microsoft/BotFramework-WebChat/issues/pull/5097) - Fixes [#5111](https://github.com/microsoft/BotFramework-WebChat/issues/5111). Fixed keyboard help screen to use HTML description list, by [@compulim](https://github.com/compulim), in PR [#5116](https://github.com/microsoft/BotFramework-WebChat/issues/pull/5116) +- Fixes [#5080](https://github.com/microsoft/BotFramework-WebChat/issues/5080). Fixed `dateToLocaleISOString` for handling sub-hour, by [@marclundgren](https://github.com/marclundgren), in PR [#5114](https://github.com/microsoft/BotFramework-WebChat/pull/5114) ### Changed diff --git a/packages/core/src/utils/dateToLocaleISOString.newfoundland.spec.js b/packages/core/src/utils/dateToLocaleISOString.newfoundland.spec.js new file mode 100644 index 0000000000..0f783d687a --- /dev/null +++ b/packages/core/src/utils/dateToLocaleISOString.newfoundland.spec.js @@ -0,0 +1,14 @@ +/** + * @jest-environment ../../../__tests__/setup/jestNodeEnvironmentWithTimezone.js + * @timezone America/St_Johns + */ + +import dateToLocaleISOString from './dateToLocaleISOString'; + +test('formatting a time in Cananda, Newfoundland timezone', () => { + // eslint-disable-next-line no-magic-numbers + const date = new Date(Date.UTC(2000, 0, 1, 0, 12, 34, 567)); + const actual = dateToLocaleISOString(date); + + 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' }`; }