Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #228 -- Better handling of timezones. Thanks, rmunn

git-svn-id: http://code.djangoproject.com/svn/django/trunk@347 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 47ce61533a5364c6d45803a696d86cbcb1ed2b33 1 parent 017b875
Adrian Holovaty authored July 29, 2005

Showing 1 changed file with 10 additions and 2 deletions. Show diff stats Hide diff stats

  1. 12  django/core/db/typecasts.py
12  django/core/db/typecasts.py
@@ -21,8 +21,16 @@ def typecast_timestamp(s): # does NOT store time zone information
21 21
     # "2005-07-29 09:56:00-05"
22 22
     if not s: return None
23 23
     d, t = s.split()
24  
-    if t[-3] in ('-', '+'):
25  
-        t = t[:-3] # Remove the time-zone information, if it exists.
  24
+    # Extract timezone information, if it exists. Currently we just throw
  25
+    # it away, but in the future we may make use of it.
  26
+    if '-' in t:
  27
+        t, tz = t.split('-', 1)
  28
+        tz = '-' + tz
  29
+    elif '+' in t:
  30
+        t, tz = t.split('+', 1)
  31
+        tz = '+' + tz
  32
+    else:
  33
+        tz = ''
26 34
     dates = d.split('-')
27 35
     times = t.split(':')
28 36
     seconds = times[2]

0 notes on commit 47ce615

Please sign in to comment.
Something went wrong with that request. Please try again.