Skip to content

Bug in parsing date-strings #378

@wimbarelds

Description

@wimbarelds

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions