]> granicus.if.org Git - python/commitdiff
Add mktime_tz() which turns a date_tz 10-tuple into a standard Unix timestamp.
authorGuido van Rossum <guido@python.org>
Thu, 12 Dec 1996 18:39:54 +0000 (18:39 +0000)
committerGuido van Rossum <guido@python.org>
Thu, 12 Dec 1996 18:39:54 +0000 (18:39 +0000)
Lib/rfc822.py

index dc5e7144975a7a081830d1f8a2cb6c0cb3f6839c..1ea2f5f8d9c69036b944d4a96f7755d4b0348625 100644 (file)
@@ -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