changeset: 77570:336c53c1f547 user: Alexander Belopolsky date: Fri Jun 22 12:25:57 2012 -0400 files: Lib/datetime.py Lib/test/datetimetester.py description: Issue #9527: datetime.astimezone() method will now supply a class timezone instance corresponding to the system local timezone when called with no arguments. diff -r 88a5f2730579 -r 336c53c1f547 Lib/datetime.py --- a/Lib/datetime.py Fri Jun 22 12:23:23 2012 -0400 +++ b/Lib/datetime.py Fri Jun 22 12:25:57 2012 -0400 @@ -1501,7 +1501,7 @@ 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 @@ 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") diff -r 88a5f2730579 -r 336c53c1f547 Lib/test/datetimetester.py --- a/Lib/test/datetimetester.py Fri Jun 22 12:23:23 2012 -0400 +++ b/Lib/test/datetimetester.py Fri Jun 22 12:25:57 2012 -0400 @@ -3283,11 +3283,11 @@ 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

AltStyle によって変換されたページ (->オリジナル) /