Code

Opened 8 years ago

Closed 6 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: UI/UX:

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@… 8 years ago.
Time zone patch

Download all attachments as: .zip

Change History (5)

Changed 8 years ago by bahamut@…

Time zone patch

comment:1 Changed 8 years ago by bahamut@…

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

comment:2 Changed 7 years ago by SmileyChris

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

comment:3 Changed 7 years ago by SmileyChris

  • Patch needs improvement set
  • Triage Stage changed from Unreviewed to Design 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 Changed 6 years ago by jacob

  • Resolution set to duplicate
  • Status changed from new to closed

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

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.