Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug in parsing date-strings #378

Open
wimbarelds opened this issue Aug 14, 2024 · 1 comment · May be fixed by #379
Open

Bug in parsing date-strings #378

wimbarelds opened this issue Aug 14, 2024 · 1 comment · May be fixed by #379

Comments

@wimbarelds
Copy link

wimbarelds commented Aug 14, 2024

Describe the bug

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

@wimbarelds
Copy link
Author

Pull request with fix: #379

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant