summaryrefslogtreecommitdiffstats
path: root/Lib/rfc822.py
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1998-02-19 00:28:58 (GMT)
committerGuido van Rossum <guido@python.org>1998-02-19 00:28:58 (GMT)
commita73033fcc2916a416561bfad384afb900f207a27 (patch)
tree6e2dfb656adf07f2a5909e6aa2cb3687b7b4cf2c /Lib/rfc822.py
parentce0e17555424a90d6dd3f5ae8f4e586280dc3b44 (diff)
downloadcpython-a73033fcc2916a416561bfad384afb900f207a27.zip
cpython-a73033fcc2916a416561bfad384afb900f207a27.tar.gz
cpython-a73033fcc2916a416561bfad384afb900f207a27.tar.bz2
Feature added by Bill van Melle: when no timezone is present, assume
local time -- that's better than failure.
Diffstat (limited to 'Lib/rfc822.py')
-rw-r--r--Lib/rfc822.py21
1 files changed, 14 insertions, 7 deletions
diff --git a/Lib/rfc822.py b/Lib/rfc822.py
index f58543a..967a85e 100644
--- a/Lib/rfc822.py
+++ b/Lib/rfc822.py
@@ -660,7 +660,7 @@ def parsedate_tz(data):
tss = string.atoi(tss)
except string.atoi_error:
return None
- tzoffset=0
+ tzoffset=None
tz=string.upper(tz)
if _timezones.has_key(tz):
tzoffset=_timezones[tz]
@@ -670,10 +670,13 @@ def parsedate_tz(data):
except string.atoi_error:
pass
# Convert a timezone offset into seconds ; -0500 -> -18000
- if tzoffset<0: tzsign=-1
- else: tzsign=1
- tzoffset=tzoffset*tzsign
- tzoffset = tzsign * ( (tzoffset/100)*3600 + (tzoffset % 100)*60)
+ if tzoffset:
+ if tzoffset < 0:
+ tzsign = -1
+ tzoffset = -tzoffset
+ else:
+ tzsign = 1
+ tzoffset = tzsign * ( (tzoffset/100)*3600 + (tzoffset % 100)*60)
tuple = (yy, mm, dd, thh, tmm, tss, 0, 0, 0, tzoffset)
return tuple
@@ -695,8 +698,12 @@ def mktime_tz(data):
switch dates. Not enough to worry about for common use.
"""
- t = time.mktime(data[:8] + (0,))
- return t - data[9] - time.timezone
+ if data[9] is None:
+ # No zone info, so localtime is better assumption than GMT
+ return time.mktime(data[:8] + (-1,))
+ else:
+ t = time.mktime(data[:8] + (0,))
+ return t - data[9] - time.timezone
# When used as script, run a small test program.