[Python-checkins] r82643 - sandbox/branches/py3k-datetime/datetime.py

alexander.belopolsky python-checkins at python.org
Thu Jul 8 02:13:56 CEST 2010


Author: alexander.belopolsky
Date: Thu Jul  8 02:13:56 2010
New Revision: 82643

Log:
Use named argument in timedelta.

Modified:
   sandbox/branches/py3k-datetime/datetime.py

Modified: sandbox/branches/py3k-datetime/datetime.py
==============================================================================
--- sandbox/branches/py3k-datetime/datetime.py	(original)
+++ sandbox/branches/py3k-datetime/datetime.py	Thu Jul  8 02:13:56 2010
@@ -208,8 +208,8 @@
                                     offset = -offset
                                     sign = '-'
                                 h, m = divmod(offset, timedelta(hours=1))
-                                assert not m % timedelta(0, 60), "whole minute"
-                                m //= timedelta(0, 60)
+                                assert not m % timedelta(minutes=1), "whole minute"
+                                m //= timedelta(minutes=1)
                                 zreplace = '%c%02d%02d' % (sign, h, m)
                     assert '%' not in zreplace
                     newformat.append(zreplace)
@@ -256,7 +256,7 @@
     if not isinstance(offset, timedelta):
         raise TypeError("tzinfo.%s() must return None "
                         "or timedelta, not '%s'" % (name, type(offset)))
-    if offset % timedelta(0, 60) or offset.microseconds:
+    if offset % timedelta(minutes=1) or offset.microseconds:
         raise ValueError("tzinfo.%s() must return a whole number "
                          "of minutes, got %s" % (name, offset))
     if not -timedelta(1) < offset < timedelta(1):
@@ -1119,8 +1119,8 @@
                         other._microsecond))
         if myoff is None or otoff is None:
             raise TypeError("cannot compare naive and aware times")
-        myhhmm = self._hour * 60 + self._minute - myoff//timedelta(0, 60)
-        othhmm = other._hour * 60 + other._minute - otoff//timedelta(0, 60)
+        myhhmm = self._hour * 60 + self._minute - myoff//timedelta(minutes=1)
+        othhmm = other._hour * 60 + other._minute - otoff//timedelta(minutes=1)
         return _cmp((myhhmm, self._second, self._microsecond),
                     (othhmm, other._second, other._microsecond))
 
@@ -1131,8 +1131,8 @@
             return hash(self._getstate()[0])
         h, m = divmod(timedelta(hours=self.hour, minutes=self.minute) - tzoff,
                       timedelta(hours=1))
-        assert not m % timedelta(0, 60), "whole minute"
-        m //= timedelta(0, 60)
+        assert not m % timedelta(minutes=1), "whole minute"
+        m //= timedelta(minutes=1)
         if 0 <= h < 24:
             return hash(time(h, m, self.second, self.microsecond))
         return hash((h, m, self.second, self.microsecond))
@@ -1149,8 +1149,8 @@
             else:
                 sign = "+"
             hh, mm = divmod(off, timedelta(hours=1))
-            assert not mm % timedelta(0, 60), "whole minute"
-            mm //= timedelta(0, 60)
+            assert not mm % timedelta(minutes=1), "whole minute"
+            mm //= timedelta(minutes=1)
             assert 0 <= hh < 24
             off = "%s%02d%s%02d" % (sign, hh, sep, mm)
         return off
@@ -1528,8 +1528,8 @@
             else:
                 sign = "+"
             hh, mm = divmod(off, timedelta(hours=1))
-            assert not mm % timedelta(0, 60), "whole minute"
-            mm //= timedelta(0, 60)
+            assert not mm % timedelta(minutes=1), "whole minute"
+            mm //= timedelta(minutes=1)
             s += "%s%02d:%02d" % (sign, hh, mm)
         return s
 


More information about the Python-checkins mailing list