diff options
Diffstat (limited to 'Doc/lib/tzinfo-examples.py')
-rw-r--r-- | Doc/lib/tzinfo-examples.py | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/Doc/lib/tzinfo-examples.py b/Doc/lib/tzinfo-examples.py index 1d3b3c4..868755a 100644 --- a/Doc/lib/tzinfo-examples.py +++ b/Doc/lib/tzinfo-examples.py @@ -1,16 +1,18 @@ -from datetime import tzinfo +from datetime import tzinfo, timedelta + +ZERO = timedelta(0) class UTC(tzinfo): """UTC""" def utcoffset(self, dt): - return 0 + return ZERO def tzname(self, dt): return "UTC" def dst(self, dt): - return 0 + return ZERO class FixedOffset(tzinfo): """Fixed offset in minutes east from UTC.""" @@ -26,8 +28,7 @@ class FixedOffset(tzinfo): return self.__name def dst(self, dt): - # It depends on more than we know in an example. - return None # Indicate we don't know + return ZERO import time @@ -43,9 +44,9 @@ class LocalTime(tzinfo): def utcoffset(self, dt): if self._isdst(dt): - return -time.timezone/60 + return timedelta(seconds=-time.timezone) else: - return -time.altzone/60 + return timedelta(seconds=-time.altzone) def tzname(self, dt): return time.tzname[self._isdst(dt)] |