Skip to content

NonExistentTimeError thrown during DST transition #70

@babus

Description

@babus

Here is my model field, I need to show all the obsolete timezones as the frontend clients still send the timezone in obsolete formats(Asia/Calcutta instead of Asia/Kokatta). Not sure if that's the reason.

TIMEZONE_CHOICES = [(pytz.timezone(tz), tz) for tz in pytz.all_timezones]

timezone = TimeZoneField(choices_display='WITH_GMT_OFFSET', choices=TIMEZONE_CHOICES, blank=True, null=True)

Error

timezone = TimeZoneField(choices_display='WITH_GMT_OFFSET', choices=TIMEZONE_CHOICES, blank=True, null=True)
  File "timezone_field/fields.py", line 72, in __init__
    choices = with_gmt_offset(values)
  File "timezone_field/choices.py", line 32, in with_gmt_offset
    delta = pytz.timezone(tz_str).utcoffset(now)
  File "pytz/tzinfo.py", line 422, in utcoffset
    dt = self.localize(dt, is_dst)
  File "pytz/tzinfo.py", line 341, in localize
    raise NonExistentTimeError(dt)

Sentry error stack

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions