Skip to content

Months are computed wrongly when using format-locale in a negative offset timezone #817

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

Closed
brunolopesr opened this issue Apr 8, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@brunolopesr
Copy link

brunolopesr commented Apr 8, 2024

Describe the bug
When using the prop format-locale with a browser using a timezone different from UTC (probably timezones with negative offsets like America/Sao_Paulo), the months of a year are computed wrong, from December to November.

To Reproduce
Set your browser timezone to a value different from UTC or +00:00, then use a date-fns locale as a value of the prop format-locale

Codesandbox: https://codesandbox.io/p/devbox/prod-glitter-lm5nsv

Expected behavior
The months should be in the correct order from January to December

Screenshots
image

Desktop & mobile (please complete the following information):

  • Browser: Google Chrome 123.0.6312.105
  • Library version: v8.4.0
@brunolopesr brunolopesr added awaiting triage The issue is not reviewed by the maintainers bug Something isn't working labels Apr 8, 2024
@Jasenkoo Jasenkoo removed the awaiting triage The issue is not reviewed by the maintainers label Apr 8, 2024
@brunolopesr
Copy link
Author

brunolopesr commented Apr 8, 2024

Made a PR #818 that I think will fix this problem.

I believe it just occurs in negative timezone offsets, because as the ISO 8601 strings used to compute month dates are always something like 2017-01-01T00:00-00:00, it then makes a date one day earlier, that will be the last day of the previous month.

@brunolopesr brunolopesr changed the title Months are computed wrongly when using format-locale in a non-UTC timezone Months are computed wrongly when using format-locale in a negative offset timezone Apr 8, 2024
@brunolopesr
Copy link
Author

Well, the bug exists in this package for at least 9 months, made the PR above to fix the problem and it was closed because the maintainer has a simpler fix..

As I don't want to wait for this fix, as I dont know if it will be in the next day or the next year, I'm closing the issue.

@brunolopesr brunolopesr closed this as not planned Won't fix, can't repro, duplicate, stale Apr 11, 2024
@Jasenkoo Jasenkoo reopened this Apr 11, 2024
@Jasenkoo
Copy link
Contributor

WIll keep it open, as it will be fixed in the next release

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants