On 2011-06-29, at 5:27 AM, Daniel Swarbrick wrote: > Storing the TZ in a separate field is going to get pretty nasty for > sorting as well, as the query will have to somehow concatenate or > compute together the two fields before applying the sorting algorithm.
I don't see why. If the datetime data is all normalized to UTC then the datetime column can be used for sorting on its own and the tz data can be ignored. > I think the best way to handle multi-TZ timestamps is the way that > Unix and other multi-user, multi-timezone OSes have been doing it for > decades (mostly wrt to filesystems) - respect the TZ of the client > inputting the data, normalize to a common TZ (usually UTC) and store > as such. Perform all sorting and timestamp comparison/arithmetic in > that single, normalized TZ. Upon output, render the value in the > client's TZ. > > ...and that is essentially what Postgres does. I think we agree here. I'm suggesting the separate tz field as a nice-to-have. I think Django has everything it needs to make DateTimeField timezone-aware. It sounds like its already doing the right thing with postgresql. It just needs a graceful fallback for other DBs that don't do timezones as well. Here's my proposal for adding timezone support to DateTimeField: 1. Assume timezone-less datetimes are in the timezone specified in settings and convert them to timezone-aware datetimes 2. If the db bridge doesn't understand timezone data, normalize the datetimes to UTC before sending them through 3. When retrieving datetimes from the db, assume they are in UTC if they don't come with a timezone already attached 4. Convert the datetimes to the timezone specified in settings Bonus: 5. Allow the user to specify a field in the DateTimeField declaration to be used for storing timezone data 6. When storing, extract the timezone and record it in this field 7. When retrieving, convert the datetime from UTC to the timezone specified in the field I could put together a patch for this solution if you folks think it looks promising. Sam -- You received this message because you are subscribed to the Google Groups "Django developers" group. To post to this group, send email to django-developers@googlegroups.com. To unsubscribe from this group, send email to django-developers+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-developers?hl=en.