[Zope3-checkins] CVS: Zope3/src/zope/app - datetimeutils.py:1.3

Tim Peters tim.one@comcast.net
Thu, 2 Jan 2003 16:12:34 -0500


Update of /cvs-repository/Zope3/src/zope/app
In directory cvs.zope.org:/tmp/cvs-serv17999/src/zope/app

Modified Files:
	datetimeutils.py 
Log Message:
The tzinfo methods utcoffset() and dst() must return a timedelta object 
(or None) now.  In 2.3a1 they could also return an int or long, but that 
was an unhelpfully redundant leftover from an earlier version wherein 
they couldn't return a timedelta.  TOOWTDI.


=== Zope3/src/zope/app/datetimeutils.py 1.2 => 1.3 ===
--- Zope3/src/zope/app/datetimeutils.py:1.2	Wed Dec 25 09:12:24 2002
+++ Zope3/src/zope/app/datetimeutils.py	Thu Jan  2 16:12:31 2003
@@ -954,12 +954,15 @@
 parse = parser.parse
 time = parser.time
 
-from datetime import tzinfo as _tzinfo
+from datetime import tzinfo as _tzinfo, timedelta as _timedelta
+_ZERO = _timedelta(0)
 class tzinfo(_tzinfo):
 
     __slots__ = ('offset', )
 
     def __init__(self, offset):
+        if isinstance(offset, int):
+            offset = _timedelta(minutes=offset)
         self.offset = offset
 
     def utcoffset(self, dt=None):
@@ -968,11 +971,12 @@
     __getstate__ = utcoffset
     __setstate__ = __init__
 
-    def dst(self, dt): return 0
+    def dst(self, dt): return _ZERO
     def tzname(self, dt): return ''
 
     def __repr__(self):
-        return 'tzinfo(%d)' % self.offset
+        minutes = self.offset.days * 24 * 60  + self.offset.seconds // 60
+        return 'tzinfo(%d)' % minutes
 
 
 from datetime import datetimetz as _datetimetz