#17580 closed Bug (fixed)
DateTimeFields don't handle timezones when given datetime.date 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 |
Description
When DateTimeFields get passed datetime.date instances it converts the values in datetime.datetime values, without using the new timezone feature.
source:django/trunk/django/db/models/fields/__init__.py?rev=17148#L750
Change History (5)
comment:1 by , 14 years ago
| Owner: | changed from to |
|---|---|
| Severity: | Normal → Release blocker |
| Triage Stage: | Unreviewed → Accepted |
comment:2 by , 14 years ago
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 by , 14 years ago
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.
When time zone support is enabled, the date value should be converted to an aware datetime in the default time zone, with a warning.