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

Timezone localization not correct when used with fullcalendar #556

Open
lausek opened this issue Sep 2, 2023 · 0 comments
Open

Timezone localization not correct when used with fullcalendar #556

lausek opened this issue Sep 2, 2023 · 0 comments

Comments

@lausek
Copy link

lausek commented Sep 2, 2023

When used together with fullcalendar the api endpoint uses the wrong query parameter to set the timezone. api_occurrences expects a query parameter called timezone, but fullcalendar sends it as timeZone (see Latest Docs). Consequently, the backend does not localize timestamps at all and falls back to UTC.

As fullcalendar is a popular addition to django-scheduler, I think the backend should be able to handle both query parameter names.

Possible fix

If timezone wasn't found in the query, try again with timeZone:

    if not timezone:
        timezone = request.GET.get("timeZone")

https://github.com/llazzaro/django-scheduler/blob/8aa6f877f17e5b05f17d7c39e93d8e73625b0a65/schedule/views.py#L340C1-L340C1

Possible workaround

When defining the fullcalendar instance in the frontend, the timezone can be added manually to the events endpoint:

// defaults to UTC
var calendar = new FullCalendar.Calendar(mountNode, {
    events: "/schedule/api/occurrences?calendar_slug=default",
    timeZone: "Europe/Berlin",
    // ...
});

// Uses the correct timezone in backend
var calendar = new FullCalendar.Calendar(mountNode, {
    events: "/schedule/api/occurrences?calendar_slug=default&timezone=Europe%2FBerlin",
    timeZone: "Europe/Berlin",
    // ...
});

Additional information

  • fullcalendar: v5.10.2
  • django-scheduler: 0.9.6
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