]> granicus.if.org Git - python/commitdiff
Issue #9527: datetime.astimezone() method will now supply a class
authorAlexander Belopolsky <alexander.belopolsky@gmail.com>
Fri, 22 Jun 2012 16:25:57 +0000 (12:25 -0400)
committerAlexander Belopolsky <alexander.belopolsky@gmail.com>
Fri, 22 Jun 2012 16:25:57 +0000 (12:25 -0400)
timezone instance corresponding to the system local timezone when
called with no arguments.

Lib/datetime.py
Lib/test/datetimetester.py

index ce88d852092d5043129f850af27d84660ade9083..e4d716198ff0f8cfd4ecffbffbedf9513a04e444 100644 (file)
@@ -1501,7 +1501,7 @@ class datetime(date):
             localtm = _time.localtime(ts)
             local = datetime(*localtm[:6])
             try:
-                # Extract TZ data if available 
+                # Extract TZ data if available
                 gmtoff = localtm.tm_gmtoff
                 zone = localtm.tm_zone
             except AttributeError:
@@ -1517,7 +1517,7 @@ class datetime(date):
                     tz = timezone(delta)
             else:
                 tz = timezone(timedelta(seconds=-gmtoff), zone)
-                
+
         elif not isinstance(tz, tzinfo):
             raise TypeError("tz argument must be an instance of tzinfo")
 
index e0454472035790253fd95cd7d3aae8c84b5f1154..4181d4fe588ae84abc5914326522c32103e96bd9 100644 (file)
@@ -3283,11 +3283,11 @@ class TestDateTimeTZ(TestDateTime, TZInfoBase, unittest.TestCase):
         dt = self.theclass(2012, 11, 4, 6, 30, tzinfo=timezone.utc)
         local = dt.astimezone()
         self.assertEqual(dt, local)
-        self.assertEqual(local.strftime("%z %Z"), "+0500 EST") 
+        self.assertEqual(local.strftime("%z %Z"), "+0500 EST")
         dt = self.theclass(2012, 11, 4, 5, 30, tzinfo=timezone.utc)
         local = dt.astimezone()
         self.assertEqual(dt, local)
-        self.assertEqual(local.strftime("%z %Z"), "+0400 EDT") 
+        self.assertEqual(local.strftime("%z %Z"), "+0400 EDT")
 
     def test_aware_subtract(self):
         cls = self.theclass