Opened 18 years ago

Last modified 13 years ago

#2626 closed Bug

Datetime handling is broken when dealing with more than one time zone — at Version 9

Reported by: Tom Tobin <korpios@…> Owned by: nobody
Component: Core (Other) Version:
Severity: Normal Keywords:
Cc: mike.scott@…, nreilly@…, George Song, miracle2k, jedie, Forest Bond, bronger@…, Chris Chambers, Dan Fairs, cg@…, louis30, David Foster Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by korpios)

Django doesn't handle multiple time zones well.

Datetimes are potentially stored with a time zone offset based on settings.TIME_ZONE (only for PostgreSQL), and retrieved as naive datetime objects. This is fine when working on a standard site publishing items within a single time zone, but quickly becomes pathological when working with more than one time zone, or when transitioning an existing site to a new time zone.

I propose that Django's datetime handling be altered to ignore settings.TIME_ZONE on all database backends, and let the appropriate Fields handle time zone conversion. I've already written a DateTimeZoneField that appropriately handles multiple time zones and returns timezone-aware datetime objects; for it to work consistently, however, the PostgreSQL backends need to stop using TIMESTAMP WITH TIME ZONE and SET TIME ZONE.

In summary:

1) The PostgreSQL backends should ignore time zones completely.

2) An appropriate Field, rather than a backend, should handle time zone support; such a field would require its backend storage to always be UTC, which can only happen cleanly if the backend ignores time zones.

Discussion thread:

http://groups.google.com/group/django-developers/browse_thread/thread/b8c885389374c040

Change History (9)

comment:1 by Chris Beaven, 18 years ago

Triage Stage: UnreviewedAccepted

Go ahead, Tom - write us a patch! Check out #2447 which may be related.

I agree that the os.environ['TZ'] is an ugly hack, there are other related tickets that back this up ;)

comment:2 by korpios, 17 years ago

Reporter: changed from Tom Tobin <korpios@…> to Tom Tobin <korpios@…>

comment:3 by Brian Rosner, 17 years ago

Owner: changed from nobody to Brian Rosner
Status: newassigned

comment:4 by Mike Scott, 17 years ago

Cc: mike.scott@… added

comment:5 by Brian Rosner, 17 years ago

Owner: Brian Rosner removed
Status: assignednew

comment:6 by Brian Rosner, 17 years ago

Owner: set to nobody

comment:7 by korpios, 17 years ago

Cc: korpios@… added

comment:8 by korpios, 16 years ago

Description: modified (diff)

comment:9 by korpios, 16 years ago

Description: modified (diff)
Note: See TracTickets for help on using tickets.
Back to Top