summaryrefslogtreecommitdiffstats
path: root/Lib/rfc822.py
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1996-12-12 18:39:54 (GMT)
committerGuido van Rossum <guido@python.org>1996-12-12 18:39:54 (GMT)
commit6cdd7a0433aaf9d28ebb912276c704e755e64543 (patch)
treeedc236821201d1ed5b7a67dac87aeb5faacc1945 /Lib/rfc822.py
parent21be14709429fb6d6bcac37163930f934a51737e (diff)
downloadcpython-6cdd7a0433aaf9d28ebb912276c704e755e64543.zip
cpython-6cdd7a0433aaf9d28ebb912276c704e755e64543.tar.gz
cpython-6cdd7a0433aaf9d28ebb912276c704e755e64543.tar.bz2
Add mktime_tz() which turns a date_tz 10-tuple into a standard Unix timestamp.
Diffstat (limited to 'Lib/rfc822.py')
-rw-r--r--Lib/rfc822.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/Lib/rfc822.py b/Lib/rfc822.py
index dc5e714..1ea2f5f 100644
--- a/Lib/rfc822.py
+++ b/Lib/rfc822.py
@@ -468,6 +468,17 @@ def parsedate(data):
return t[:9]
else: return t
+def mktime_tz(data):
+ """Turn a 10-tuple as returned by parsedate_tz() into a UTC timestamp.
+
+ Minor glitch: this first interprets the first 8 elements as a
+ local time and then compensates for the timezone difference;
+ this may yield a slight error around daylight savings time
+ switch dates. Not enough to worry about for common use.
+
+ """
+ t = time.mktime(data[:8] + (0,))
+ return t + data[9] - time.timezone
# When used as script, run a small test program.
# The first command line argument must be a filename containing one