jquense / react-big-calendar

gcal/outlook like calendar component
http://jquense.github.io/react-big-calendar/examples/index.html
MIT License
7.8k stars 2.23k forks source link

Setting `min` and `max` displays calendar events a week earlier than they are scheduled the week of DST #2466

Open prestontunnellwilson opened 10 months ago

prestontunnellwilson commented 10 months ago

Check that this is really a bug

Reproduction link

https://codesandbox.io/s/react-big-calendar-example-forked-w4u7s2?file=/index.js

Bug description

Viewing a week of events the week of the daylight savings time shift (in New York timezone) results in events being displayed on hour earlier. This happens when min and max are specified.

They show the correct time in the Day view, but when November 5th, 2023 (when DST occurred), the events display one hour earlier:

calendar-event-hour-early-in-week

You can see that the min and max are different in the day with DST compared to the days without. The code specifies

  const min = useMemo(() => new Date(2023, 10, 5, 8, 0, 0, 0), []);
  const max = useMemo(() => new Date(2023, 10, 5, 21, 0, 0, 0), []);

But when November 5th, 2023 shows up the min and max are instead 0700 and 2000.

Expected Behavior

The min's and max's are the same regardless of whether the week includes the Daylight Savings time transition or not, and the calendar events show up at the same time when they are scheduled for according to the Day view.

Actual Behavior

The min's and max's are shifted an hour earlier the week of DST when in week view and the day of DST when in day view and calendar events for that week in week view show up an hour earlier.

react-big-calendar version

1.8.5

React version

18.2.0

Platform/Target and Browser Versions

macOS Chrome

Validations

Would you like to open a PR for this bug?

bu6n commented 10 months ago

What localizer are you using? luxon? Are you sure this is related to min and max? If this is possible for you, you could test changing localizers. I fixed this bug for moment earlier this year (https://github.com/jquense/react-big-calendar/pull/2374), and it's not present in date-fns, but as far as I know it's still present in luxon.

prestontunnellwilson commented 10 months ago

What localizer are you using

This is using moment, interestingly enough:

    "moment": "2.29.4",
    "moment-timezone": "0.5.38",
bu6n commented 10 months ago

Could you try with date-fns just to see if the problem persists?

prestontunnellwilson commented 8 months ago

@bu6n I am sorry for the delay in responding! Trying with date-fns, the problem does not persist. I verified this in https://codesandbox.io/s/react-big-calendar-example-forked-g8hk7z?file=/index.js.

That seems to me to point to an issue somewhere in moment or the moment localizer. Does that match what you're thinking?

bu6n commented 8 months ago

Yes, I only use date-fns now because I had all sort of problems with moment...