Skip to content

Calendar does not render dates in Django's timezone. #436

@vsalvino

Description

@vsalvino

Describe the bug

The calendar (EventIndexPage) simply renders dates in UTC, without showing the timezone, or converting to Django's specified timezone.

Steps to reproduce

In Django settings, set (these are the default generated by coderedcms start):

USE_TZ = True
TIME_ZONE = 'America/New_York'

This will tell Django to convert all dates to New York time when rendering HTML templates.

Then create an EventIndexPage and some child EventPages.

When setting the datetimes of the EventPages, Django will consume them as New York time and save them to the database in UTC (which is the desired behavior).

When rendering these dates in the EventPage template, they are convereted back to New York time and render correctly.

However when rendering these dates on the EventIndexPage calendar (fullcalendar.js), they are shown in UTC time.

Expected behavior

The dates on the EventIndexPage calendar should be shown in TIME_ZONE time (New York time in this example)

Additional context

The fix probably likes in one of two places:

  1. Ajax view which returns the JSON calendar entries should provide the timezone offset, and fullcalendar.js should display the event in the correct timezone following the offset.

  2. Ajax view which returns the JSON calendar entries should convert them to the desired timezone, and return that. Then the calendar can be "dumb" and just display the date as a string as provided form the ajax view.

Metadata

Metadata

Assignees

Labels

Type: BugSomething isn't working

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions