From 4a30c5899c7ee4137fcd564f34d6c4005855da82 Mon Sep 17 00:00:00 2001 From: Zooko O'Whielacronx Date: Thu, 11 Jun 2009 17:09:20 -0700 Subject: [PATCH] util: oops, time.tzset() doesn't work on Windows -- hopefully the new "London" unit test passes on Windows when we skip tzset() on platforms that don't have it --- src/allmydata/test/test_util.py | 6 ++++-- src/allmydata/util/time_format.py | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/allmydata/test/test_util.py b/src/allmydata/test/test_util.py index 0f0fbba9..adb9bca4 100644 --- a/src/allmydata/test/test_util.py +++ b/src/allmydata/test/test_util.py @@ -779,7 +779,8 @@ class TimeFormat(unittest.TestCase): # that implementation to something that works even in this case...) origtz = os.environ.get('TZ') os.environ['TZ'] = "Europe/London" - time.tzset() + if hasattr(time, 'tzset'): + time.tzset() try: return self._help_test_epoch() finally: @@ -787,7 +788,8 @@ class TimeFormat(unittest.TestCase): del os.environ['TZ'] else: os.environ['TZ'] = origtz - time.tzset() + if hasattr(time, 'tzset'): + time.tzset() def _help_test_epoch(self): s = time_format.iso_utc_time_to_seconds("1970-01-01T00:00:01") diff --git a/src/allmydata/util/time_format.py b/src/allmydata/util/time_format.py index aa0b64d8..42e6aee0 100644 --- a/src/allmydata/util/time_format.py +++ b/src/allmydata/util/time_format.py @@ -44,7 +44,8 @@ def iso_utc_time_to_seconds(isotime, _conversion_re=re.compile(r"(?P\d{4}) origtz = os.environ.get('TZ') os.environ['TZ'] = "UTC" - time.tzset() + if hasattr(time, 'tzset'): + time.tzset() try: return time.mktime( (year, month, day, hour, minute, second, 0, 1, 0) ) + subsecfloat finally: @@ -52,7 +53,8 @@ def iso_utc_time_to_seconds(isotime, _conversion_re=re.compile(r"(?P\d{4}) del os.environ['TZ'] else: os.environ['TZ'] = origtz - time.tzset() + if hasattr(time, 'tzset'): + time.tzset() def parse_duration(s): orig = s -- 2.45.2