-
Notifications
You must be signed in to change notification settings - Fork 6
Description
Describe the bug
react-sdk-components/packages/react-sdk-components/src/components/helpers/formatters/index.ts
Line 12 in e4b31d4
| function getDateObject(text): Date { |
The getDateObject function in @pega/react-sdk-components/src/components/helpers/formatters/index.ts interprets DateTime strings (such as "20240814T080200.000 GMT") in the local user timezone, despite the value provided clearly being in GMT.
To Reproduce
Steps to reproduce the behavior:
import { format } from '@pega/react-sdk-components/lib/components/helpers/formatters';
console.log(format('20240814T080200.000 GMT', 'DateTime', {timezone: 'Europe/Amsterdam'}));
// The expected output (in Europe/Amsterdam timezone) would be:
// "Aug 14, 2024 10:02 AM"
// The actual result is
// "Aug 14, 2024 12:02 PM"Note that, the "actual result" will differ if you run this code from a different timezone, because the input string is parsed in your local timezone regardless of all other things.
Expected behavior
See above
Screenshots
Not applicable
Desktop (please complete the following information):
- OS: MacOS 14.3.1 (23D60)
- Browser: Chrome
- Version: 126.0.6478.183
- (this is not relevant)
Smartphone (please complete the following information):
- Not relevant
Additional context
I will create a pull request to fix this