Author: mtredinnick
Date: 2009-02-27 22:52:16 -0600 (Fri, 27 Feb 2009)
New Revision: 9920

Modified:
   django/branches/releases/1.0.X/django/utils/dateformat.py
Log:
[1.0.X] Fixed #10048 -- Handle non-existent timezone in dateformat functions.

Backport of r9919 from trunk.

Modified: django/branches/releases/1.0.X/django/utils/dateformat.py
===================================================================
--- django/branches/releases/1.0.X/django/utils/dateformat.py   2009-02-28 
04:51:13 UTC (rev 9919)
+++ django/branches/releases/1.0.X/django/utils/dateformat.py   2009-02-28 
04:52:16 UTC (rev 9920)
@@ -131,7 +131,7 @@
 
     def I(self):
         "'1' if Daylight Savings Time, '0' otherwise."
-        if self.timezone.dst(self.data):
+        if self.timezone and self.timezone.dst(self.data):
             return u'1'
         else:
             return u'0'
@@ -192,14 +192,14 @@
 
     def T(self):
         "Time zone of this machine; e.g. 'EST' or 'MDT'"
-        name = self.timezone.tzname(self.data)
+        name = self.timezone and self.timezone.tzname(self.data) or None
         if name is None:
             name = self.format('O')
         return unicode(name)
 
     def U(self):
         "Seconds since the Unix epoch (January 1 1970 00:00:00 GMT)"
-        off = self.timezone.utcoffset(self.data)
+        off = self.timezone and self.timezone.utcoffset(self.data) or 0
         return int(time.mktime(self.data.timetuple())) + off.seconds * 60
 
     def w(self):
@@ -253,6 +253,8 @@
         timezones west of UTC is always negative, and for those east of UTC is
         always positive.
         """
+        if not self.timezone:
+            return 0
         offset = self.timezone.utcoffset(self.data)
         # Only days can be negative, so negative offsets have days=-1 and
         # seconds positive. Positive offsets have days=0


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to