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

fix: Format date localized #3003

Merged
merged 2 commits into from
Nov 13, 2024
Merged

fix: Format date localized #3003

merged 2 commits into from
Nov 13, 2024

Conversation

georgylobko
Copy link
Contributor

Description

This PR addresses the problem described in the ticket AWSUI-59971 when the date that includes a negative timezone in relation to UTC is parsed incorrectly.

Related links, issue #, if available: n/a

How has this been tested?

Review checklist

The following items are to be evaluated by the author(s) and the reviewer(s).

Correctness

  • Changes include appropriate documentation updates.
  • Changes are backward-compatible if not indicated, see CONTRIBUTING.md.
  • Changes do not include unsupported browser features, see CONTRIBUTING.md.
  • Changes were manually tested for accessibility, see accessibility guidelines.

Security

Testing

  • Changes are covered with new/existing unit tests?
  • Changes are covered with new/existing integration tests?

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Copy link

codecov bot commented Nov 12, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.30%. Comparing base (6539f15) to head (2162e6e).
Report is 7 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3003   +/-   ##
=======================================
  Coverage   96.30%   96.30%           
=======================================
  Files         771      777    +6     
  Lines       21820    21877   +57     
  Branches     7450     7480   +30     
=======================================
+ Hits        21013    21069   +56     
+ Misses        799      755   -44     
- Partials        8       53   +45     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

// Store original timezone offset method
const originalTimezoneOffset = Date.prototype.getTimezoneOffset;

// Mock to simulate Pacific Time (UTC-8/UTC-7)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as an alternative, it could be achieved via using https://www.npmjs.com/package/timezone-mock lib

@georgylobko georgylobko marked this pull request as ready for review November 12, 2024 11:10
@georgylobko georgylobko requested a review from a team as a code owner November 12, 2024 11:10
@georgylobko georgylobko requested review from abdhalees and jperals and removed request for a team and abdhalees November 12, 2024 11:10
@@ -0,0 +1,36 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I ran this test locally without the changes in format-date-localized and it also passed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh right, because I reproduced this problem locally after changing my system timezone to pacific

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I rewrote this as an integration test because the only way to test it in a unit test environment would be to set up a separate environment with a global timezone. Moreover, the integration test I added now fully covers the original bug scenario.

@georgylobko georgylobko added this pull request to the merge queue Nov 13, 2024
Merged via the queue into main with commit e001dad Nov 13, 2024
38 checks passed
@georgylobko georgylobko deleted the fix/format-date-localized branch November 13, 2024 11:51
timogasda pushed a commit that referenced this pull request Nov 18, 2024
jperals added a commit that referenced this pull request Nov 20, 2024
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 this pull request may close these issues.

2 participants