[Checkins] SVN: DateTime/trunk/ Allow timezone argument to be a Unicode string while creating a DateTime object using two arguments.

Hano Schlichting cvs-admin at zope.org
Sun Jan 20 17:52:15 UTC 2013


Log message for revision 129060:
  Allow timezone argument to be a Unicode string while creating a DateTime object using two arguments.
  

Changed:
  U   DateTime/trunk/CHANGES.txt
  U   DateTime/trunk/src/DateTime/DateTime.py
  U   DateTime/trunk/src/DateTime/tests/testDateTime.py

-=-
Modified: DateTime/trunk/CHANGES.txt
===================================================================
--- DateTime/trunk/CHANGES.txt	2013-01-19 21:59:57 UTC (rev 129059)
+++ DateTime/trunk/CHANGES.txt	2013-01-20 17:52:14 UTC (rev 129060)
@@ -4,6 +4,8 @@
 3.0.3 (unreleased)
 ------------------
 
+- Allow timezone argument to be a Unicode string while creating a DateTime
+  object using two arguments.
 
 3.0.2 (2012-10-21)
 ------------------

Modified: DateTime/trunk/src/DateTime/DateTime.py
===================================================================
--- DateTime/trunk/src/DateTime/DateTime.py	2013-01-19 21:59:57 UTC (rev 129059)
+++ DateTime/trunk/src/DateTime/DateTime.py	2013-01-20 17:52:14 UTC (rev 129060)
@@ -729,7 +729,7 @@
                     tz = self._calcTimezoneName(x, ms)
                 s, d, t, microsecs = _calcIndependentSecondEtc(tz, x, ms)
 
-            elif (isinstance(arg, (unicode, str)) and
+            elif (isinstance(arg, basestring) and
                   arg.lower() in _TZINFO._zidx):
                 # Current time, to be displayed in specified timezone
                 t, tz = time(), _TZINFO._zmap[arg.lower()]
@@ -739,7 +739,7 @@
                 x = _calcDependentSecond(tz, t)
                 yr, mo, dy, hr, mn, sc = _calcYMDHMS(x, ms)
 
-            elif isinstance(arg, (unicode, str)):
+            elif isinstance(arg, basestring):
                 # Date/time string
 
                 iso8601 = iso8601Match(arg.strip())
@@ -780,7 +780,7 @@
                 sc = sc + ms
 
         elif ac==2:
-            if isinstance(args[1], str):
+            if isinstance(args[1], basestring):
                 # Seconds from epoch (gmt) and timezone
                 t, tz = args
                 ms = (t - math.floor(t))

Modified: DateTime/trunk/src/DateTime/tests/testDateTime.py
===================================================================
--- DateTime/trunk/src/DateTime/tests/testDateTime.py	2013-01-19 21:59:57 UTC (rev 129059)
+++ DateTime/trunk/src/DateTime/tests/testDateTime.py	2013-01-20 17:52:14 UTC (rev 129060)
@@ -116,6 +116,8 @@
         dt = DateTime()
         dt1 = DateTime(float(dt), dt.timezone())
         self.assertEqual(str(dt), str(dt1), (dt, dt1))
+        dt1 = DateTime(float(dt), unicode(dt.timezone()))
+        self.assertEqual(str(dt), str(dt1), (dt, dt1))
 
     def testConstructor6(self):
         # Constructor from year and julian date



More information about the checkins mailing list