﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
228	[patch] Better handling of timezones	rmunn@…	Adrian Holovaty	"The timezone-handling in [346] is still too naive: according to http://www.cl.cam.ac.uk/~mgk25/iso-time.html, timezones can be specified in any of the following forms:

+hh
+hhmm
+hh:mm
-hh
-hhmm
-hh:mm

I propose the following patch, which can deal with any of these forms. It also saves the timezone data; although we don't currently use it for anything, this patch will make a good jumping-off point in the future if we decide to use it.
{{{
Index: django/core/db/typecasts.py
===================================================================
--- django/core/db/typecasts.py (revision 346)
+++ django/core/db/typecasts.py (working copy)
@@ -21,8 +21,16 @@
     # ""2005-07-29 09:56:00-05""
     if not s: return None
     d, t = s.split()
-    if t[-3] in ('-', '+'):
-        t = t[:-3] # Remove the time-zone information, if it exists.
+    # Extract timezone information, if it exists. Currently we just throw
+    # it away, but in the future we may make use of it.
+    if '-' in t:
+        t, tz = t.split('-', 1)
+        tz = '-' + tz
+    elif '+' in t:
+        t, tz = t.split('+', 1)
+        tz = '+' + tz
+    else:
+        tz = ''
     dates = d.split('-')
     times = t.split(':')
     seconds = times[2]
}}}"	enhancement	closed	Database layer (models, ORM)		normal	fixed			Accepted	1	0	0	0	0	0
