diff options
author | Alexander Belopolsky <alexander.belopolsky@gmail.com> | 2015-09-06 17:07:21 (GMT) |
---|---|---|
committer | Alexander Belopolsky <alexander.belopolsky@gmail.com> | 2015-09-06 17:07:21 (GMT) |
commit | 7827a5b7c29ae71daf0175ce3398115374ceb50e (patch) | |
tree | 275c926de9cbabbcd65ba73ea0599d1fe0aafeb3 /Lib | |
parent | 40dc328cc2b51a008dd303776e6f7529260ddf15 (diff) | |
download | cpython-7827a5b7c29ae71daf0175ce3398115374ceb50e.zip cpython-7827a5b7c29ae71daf0175ce3398115374ceb50e.tar.gz cpython-7827a5b7c29ae71daf0175ce3398115374ceb50e.tar.bz2 |
Closes Issue#22241: timezone.utc name is now plain 'UTC', not 'UTC-00:00'.
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/datetime.py | 2 | ||||
-rw-r--r-- | Lib/test/datetimetester.py | 3 |
2 files changed, 4 insertions, 1 deletions
diff --git a/Lib/datetime.py b/Lib/datetime.py index 3bf9edc..6b2ac33 100644 --- a/Lib/datetime.py +++ b/Lib/datetime.py @@ -1920,6 +1920,8 @@ class timezone(tzinfo): @staticmethod def _name_from_offset(delta): + if not delta: + return 'UTC' if delta < timedelta(0): sign = '-' delta = -delta diff --git a/Lib/test/datetimetester.py b/Lib/test/datetimetester.py index b8c9b0d..f23add3 100644 --- a/Lib/test/datetimetester.py +++ b/Lib/test/datetimetester.py @@ -258,7 +258,8 @@ class TestTimeZone(unittest.TestCase): with self.assertRaises(TypeError): self.EST.dst(5) def test_tzname(self): - self.assertEqual('UTC+00:00', timezone(ZERO).tzname(None)) + self.assertEqual('UTC', timezone.utc.tzname(None)) + self.assertEqual('UTC', timezone(ZERO).tzname(None)) self.assertEqual('UTC-05:00', timezone(-5 * HOUR).tzname(None)) self.assertEqual('UTC+09:30', timezone(9.5 * HOUR).tzname(None)) self.assertEqual('UTC-00:01', timezone(timedelta(minutes=-1)).tzname(None)) |