summaryrefslogtreecommitdiffstats
path: root/Lib/http
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@haypocalc.com>2011-03-21 01:51:38 (GMT)
committerVictor Stinner <victor.stinner@haypocalc.com>2011-03-21 01:51:38 (GMT)
commit56f9a0221b097590436add843b6c96cf8b657af4 (patch)
tree0d63efef981f11207334913896b6ed5946069742 /Lib/http
parent6f0e4f99ab2f14864557e7f8dda1d575dd0e1f6c (diff)
parent628225c0d1647b1cdc804f8b1bfa3080ca5b213c (diff)
downloadcpython-56f9a0221b097590436add843b6c96cf8b657af4.zip
cpython-56f9a0221b097590436add843b6c96cf8b657af4.tar.gz
cpython-56f9a0221b097590436add843b6c96cf8b657af4.tar.bz2
merge 3.1
Diffstat (limited to 'Lib/http')
-rw-r--r--Lib/http/cookiejar.py18
1 files changed, 12 insertions, 6 deletions
diff --git a/Lib/http/cookiejar.py b/Lib/http/cookiejar.py
index 7f7f55b..9d798e8 100644
--- a/Lib/http/cookiejar.py
+++ b/Lib/http/cookiejar.py
@@ -29,6 +29,7 @@ __all__ = ['Cookie', 'CookieJar', 'CookiePolicy', 'DefaultCookiePolicy',
'FileCookieJar', 'LWPCookieJar', 'LoadError', 'MozillaCookieJar']
import copy
+import datetime
import re
import time
import urllib.parse, urllib.request
@@ -97,10 +98,12 @@ def time2isoz(t=None):
1994-11-24 08:49:37Z
"""
- if t is None: t = time.time()
- year, mon, mday, hour, min, sec = time.gmtime(t)[:6]
+ if t is None:
+ dt = datetime.datetime.utcnow()
+ else:
+ dt = datetime.datetime.utcfromtimestamp(t)
return "%04d-%02d-%02d %02d:%02d:%02dZ" % (
- year, mon, mday, hour, min, sec)
+ dt.year, dt.month, dt.day, dt.hour, dt.minute, dt.second)
def time2netscape(t=None):
"""Return a string representing time in seconds since epoch, t.
@@ -113,10 +116,13 @@ def time2netscape(t=None):
Wed, DD-Mon-YYYY HH:MM:SS GMT
"""
- if t is None: t = time.time()
- year, mon, mday, hour, min, sec, wday = time.gmtime(t)[:7]
+ if t is None:
+ dt = datetime.datetime.utcnow()
+ else:
+ dt = datetime.datetime.utcfromtimestamp(t)
return "%s %02d-%s-%04d %02d:%02d:%02d GMT" % (
- DAYS[wday], mday, MONTHS[mon-1], year, hour, min, sec)
+ DAYS[dt.weekday()], dt.day, MONTHS[dt.month-1],
+ dt.year, dt.hour, dt.minute, dt.second)
UTC_ZONES = {"GMT": None, "UTC": None, "UT": None, "Z": None}