Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #10048 -- Handle non-existent timezone in dateformat functions.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@9919 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit b337884fcf6b2c1934d380dd99bbe485d3b88f3a 1 parent beb2005
Malcolm Tredinnick authored February 28, 2009

Showing 1 changed file with 5 additions and 3 deletions. Show diff stats Hide diff stats

  1. 8  django/utils/dateformat.py
8  django/utils/dateformat.py
@@ -131,7 +131,7 @@ def F(self):
131 131
 
132 132
     def I(self):
133 133
         "'1' if Daylight Savings Time, '0' otherwise."
134  
-        if self.timezone.dst(self.data):
  134
+        if self.timezone and self.timezone.dst(self.data):
135 135
             return u'1'
136 136
         else:
137 137
             return u'0'
@@ -192,14 +192,14 @@ def t(self):
192 192
 
193 193
     def T(self):
194 194
         "Time zone of this machine; e.g. 'EST' or 'MDT'"
195  
-        name = self.timezone.tzname(self.data)
  195
+        name = self.timezone and self.timezone.tzname(self.data) or None
196 196
         if name is None:
197 197
             name = self.format('O')
198 198
         return unicode(name)
199 199
 
200 200
     def U(self):
201 201
         "Seconds since the Unix epoch (January 1 1970 00:00:00 GMT)"
202  
-        off = self.timezone.utcoffset(self.data)
  202
+        off = self.timezone and self.timezone.utcoffset(self.data) or 0
203 203
         return int(time.mktime(self.data.timetuple())) + off.seconds * 60
204 204
 
205 205
     def w(self):
@@ -253,6 +253,8 @@ def Z(self):
253 253
         timezones west of UTC is always negative, and for those east of UTC is
254 254
         always positive.
255 255
         """
  256
+        if not self.timezone:
  257
+            return 0
256 258
         offset = self.timezone.utcoffset(self.data)
257 259
         # Only days can be negative, so negative offsets have days=-1 and
258 260
         # seconds positive. Positive offsets have days=0

0 notes on commit b337884

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