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

Incorrect compare date set due to year leaps #18

Open
xxxstasiek opened this issue Oct 24, 2024 · 0 comments
Open

Incorrect compare date set due to year leaps #18

xxxstasiek opened this issue Oct 24, 2024 · 0 comments

Comments

@xxxstasiek
Copy link

Hi, when user checks compare mode, the default compared date is set to { today - 365 }, but year can have 366 days which causes incorrect compare date set, example:
image

To fix this you need to change 400 line in date-range-picker.tsx from:

setRangeCompare({
  from: new Date(
    range.from.getFullYear(),
    range.from.getMonth(),
    range.from.getDate() - 365 // remove this
  ),
...

to:

setRangeCompare({
  from: new Date(
    range.from.getFullYear() - 1, // add this
    range.from.getMonth(),
    range.from.getDate()
  ),
...

Thanks

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

No branches or pull requests

1 participant