Opened 18 years ago

Closed 16 years ago

#2447 closed enhancement (duplicate)

[patch] Experimental time zone support for date and time fields, database backend utilities

Reported by: bahamut@… Owned by: nobody
Component: Core (Other) Version:
Severity: normal Keywords: timezone, time zone, UTC
Cc: Triage Stage: Design decision needed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: yes
Easy pickings: no UI/UX: no

Description

The attached patch attempts to improve Django's support for time zones.

Specifically, it modifies the date and time fields so that they return str(self.data), which will yield an ISO 8601 formatted date, but with a space separator instead of a T. That format will include a time zone offset using the [+-]HH:MM format if the underlying datetime object is not naive. That format is understood by most databases.

It also modifies the function typecast_timestamp from db.backend.util such that it will try to parse time zone offsets. If no such format is found, it will still produce a non-naive datetime object, set in the current time zone.

Attachments (1)

[3486] time zone support.diff (6.4 KB ) - added by bahamut@… 18 years ago.
Time zone patch

Download all attachments as: .zip

Change History (5)

by bahamut@…, 18 years ago

Time zone patch

comment:1 by bahamut@…, 18 years ago

I forgot to mention, it also adds some new date / time format characters, following PHP as much as possible.

comment:2 by Chris Beaven, 17 years ago

time.tzset() is not available for Windows, you'll have to write some error checking around that.

comment:3 by Chris Beaven, 17 years ago

Patch needs improvement: set
Triage Stage: UnreviewedDesign decision needed

Due to comment # the parsing is fairly naive and should be improved I'll mark as patch needs improvement.

It does look like an interesting patch.

We'd need to run tests across all databases and platforms to see if this has any "interesting" side effects.

comment:4 by Jacob, 16 years ago

Resolution: duplicate
Status: newclosed

This is functionally a duplicate of #2626 (though that one solves the problem in a slightly different way).

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