diff -r 7937aa6b7e92 Lib/test/test_time.py --- a/Lib/test/test_time.py Tue Jul 03 13:18:30 2012 +0200 +++ b/Lib/test/test_time.py Tue Jul 03 11:00:46 2012 -0430 @@ -301,6 +301,72 @@ del environ['TZ'] time.tzset() + def test_timezone_consistency(self): + from os import environ + + org_TZ = environ.get('TZ',None) + try: + environ['TZ'] = 'GMT+0' + time.tzset() + uts = time.mktime(time.localtime()) + # http://www.timeanddate.com/worldclock/difference.html?p1=58 + tzones = [ + ('America/New_York', 18000, 14400), + ('America/Chicago', 21600, 18000), + ('America/Los_Angeles', 28800, 52200), + ('America/Toronto', 18000, 14400), + ('CET', -3600, -3600), + ('CET-2CEST', -3600, -7200), + ('EST', 18000, 14400), + ('EST4EDT', 18000, 14400), + ('CST6CDT', 21600, 18000), + ('PST7PDT', 28800, 25200), + ('UTC', 0, 0), + ('Europe/London', 0, 3600), + ('Europe/Amsterdam', -3600, 7200), + ('Europe/Kiev', -7200, -7200), + ('Brazil/East', 10800, 10800), + ('Brazil/West', 14400, 1400), + ('VET4:30', 16200, 16200), + ('GMT+4:30', 16200, 16200), + ('Europe/Moscow', -14400, -14400), + ('America/Caracas', 16200, 16200) + ] + + for tz, diff, dst in tzones: + environ['TZ'] = tz + time.tzset() + + self.assertIsNotNone(time.tzname, tz) + self.assertIn(time.timezone, [diff, dst], time.tzname) + + lts = time.mktime(time.gmtime()) - time.timezone + self.assertEqual(lts, uts, tz) + + # Show that time.timezone should not be used for calculations + # involving dates in the past. + for tz, _s, _d in tzones: + environ['TZ'] = tz + time.tzset() + fmt = '%Y/%m/%d %H:%M:%S %Z' + bt = time.mktime(time.strptime('1969/7/20 20:18:00 UTC', fmt)) + # note that strptime ignores the timezone and always + # parses as a local time + lbt = time.mktime(time.localtime(bt)) + self.assertEqual(lbt, bt, tz) + + ubt = time.mktime(time.gmtime(bt)) + self.assertEqual(ubt, bt + time.timezone, tz) + finally: + # Repair TZ environment variable in case any other tests + # rely on it. + if org_TZ is not None: + environ['TZ'] = org_TZ + elif 'TZ' in environ: + del environ['TZ'] + time.tzset() + + def test_insane_timestamps(self): # It's possible that some platform maps time_t to double, # and that this test will fail there. This test should diff -r 7937aa6b7e92 Misc/ACKS --- a/Misc/ACKS Tue Jul 03 13:18:30 2012 +0200 +++ b/Misc/ACKS Tue Jul 03 11:00:46 2012 -0430 @@ -1167,3 +1167,4 @@ Kai Zhu Tarek Ziadé Peter Åstrand +Juancarlo Añez