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

Event segments one day too short when timezone is set #2659

Open
5 tasks done
evanbrooks-codaio opened this issue Sep 30, 2024 · 1 comment
Open
5 tasks done

Event segments one day too short when timezone is set #2659

evanbrooks-codaio opened this issue Sep 30, 2024 · 1 comment
Labels

Comments

@evanbrooks-codaio
Copy link

Check that this is really a bug

  • I confirm

Reproduction link

https://codesandbox.io/p/sandbox/react-big-calendar-example-forked-wc6sts

Bug description

  • Configure a localizer with a timezone to the east of the browser's current timezone.
  • Create an event that spans multiple weeks
  • Display a month view. Note that the event segments are not spanning correctly.

I believe this may be the same issue as #2425 , however it appears to happen consistently in any timezone, and consistently with either the moment or luxon localizers. feel free consolidate if this is a duplicate.

Expected Behavior

  • Segments include the last day of the event.
  • Segments extend to the last day of the week when multi-week
image

Actual Behavior

  • Segments ends the day before the end of the event.
  • Segments omit last day of the week when multi-week. (For example, ending on friday if the last day of the week is saturday).
image

react-big-calendar version

1.14.1

React version

18.2.0

Platform/Target and Browser Versions

macOS 14.4, Chrome 129

Validations

  • Read the docs.
  • Check that there isn't already an issue that request the same feature to avoid creating a duplicate.
  • Make sure this is a react-big-calendar issue and not an implementation issue

Would you like to open a PR for this bug?

  • I'm willing to open a PR
@evanbrooks-codaio
Copy link
Author

evanbrooks-codaio commented Sep 30, 2024

The issue appears to be with the getBrowserTzOffset in the localizers, ie here for luxon. This configures the segmentOffset here and is used to explictly subtract the width of the segment here:

// The segmentOffset is necessary when adjusting for timezones
// ahead of the browser timezone
span = Math.max(span - localizer.segmentOffset, 1)

It seems like this is subtracting "1" in situations where the segments are already correct. I've found that simply removing the segmentOffset appears to resolve the issue in my test case. I'm not sure exactly when it is necessary to subtract 1 (if ever?), but it seems to happening more often than it should.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant