summaryrefslogtreecommitdiffstats
path: root/Doc/lib/tzinfo-examples.py
diff options
context:
space:
mode:
authorTim Peters <tim.peters@gmail.com>2003-01-02 21:28:08 (GMT)
committerTim Peters <tim.peters@gmail.com>2003-01-02 21:28:08 (GMT)
commit397301eccb945ea98d03d3022882900a9fd2046f (patch)
tree3990642065d13899df8b7ba51d7aeec68836be28 /Doc/lib/tzinfo-examples.py
parent4abd5f0fce54d32fbe01207e505047bd82ff9ca3 (diff)
downloadcpython-397301eccb945ea98d03d3022882900a9fd2046f.zip
cpython-397301eccb945ea98d03d3022882900a9fd2046f.tar.gz
cpython-397301eccb945ea98d03d3022882900a9fd2046f.tar.bz2
The tzinfo methods utcoffset() and dst() must return a timedelta object
(or None) now. In 2.3a1 they could also return an int or long, but that was an unhelpfully redundant leftover from an earlier version wherein they couldn't return a timedelta. TOOWTDI.
Diffstat (limited to 'Doc/lib/tzinfo-examples.py')
-rw-r--r--Doc/lib/tzinfo-examples.py15
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)]