Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#17580 closed Bug (fixed)

DateTimeFields don't handle timezones when given instances

Reported by: Jannis Leidel Owned by: Aymeric Augustin
Component: Core (Other) Version: 1.4-alpha-1
Severity: Release blocker Keywords:
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


When DateTimeFields get passed instances it converts the values in datetime.datetime values, without using the new timezone feature.


Change History (5)

comment:1 Changed 7 years ago by Aymeric Augustin

Owner: changed from nobody to Aymeric Augustin
Severity: NormalRelease blocker
Triage Stage: UnreviewedAccepted

When time zone support is enabled, the date value should be converted to an aware datetime in the default time zone, with a warning.

comment:2 Changed 7 years ago by Jannis Leidel

Agreed in general, but I don't think a warning is appropriate here. Passing a date instance is a perfectly fine use case and can't be made timezone aware like datetime instances by passing a tzinfo parameter.

comment:3 Changed 7 years ago by Aymeric Augustin

Indeed, a date can't be timezone aware, which means it can't be interpreted unambiguously as a timezone aware datetime.

That's why I proposed to raise a warning when USE_TZ = True, exactly like I do when a DateTimeField receives a naive datetime.

comment:4 Changed 7 years ago by Jannis Leidel

Resolution: fixed
Status: newclosed

In [17392]:

Fixed #17580 -- Made sure instances are correctly handled when being passed to a DateTimeField fields and the timezone support is enabled by making it aware using the default timezone.

comment:5 Changed 7 years ago by Aymeric Augustin

In [17403]:

(The changeset message doesn't reference this ticket)

Note: See TracTickets for help on using tickets.
Back to Top