[Python-bugs-list] [ python-Bugs-499169 ] imaplib.Time2Internaldate is broken
noreply@sourceforge.net
noreply@sourceforge.net
Thu, 03 Jan 2002 15:09:39 -0800
Bugs item #499169, was opened at 2002-01-03 15:09
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=499169&group_id=5470
Category: Python Library
Group: Python 2.2
Status: Open
Resolution: None
Priority: 5
Submitted By: Ben Hutchings (wom-work)
Assigned to: Nobody/Anonymous (nobody)
Summary: imaplib.Time2Internaldate is broken
Initial Comment:
The type tests in this function have stopped working
because the return type of time.gmtime() and friends is
now time.struct_time and not tuple.
Secondly, the format string used for the timezone is
'%+02d%02d'. I believe it should be '%+03d02d' since
the first field width includes the sign character.
A patch that works for me (note that it lets strftime
do its own type-checking):
--- imaplib.py~ Tue Oct 30 00:56:40 2001
+++ imaplib.py Thu Jan 3 18:42:22 2002
@@ -1070,13 +1070,12 @@
"""
dttype = type(date_time)
- if dttype is type(1) or dttype is type(1.1):
+ if dttype is str:
+ return date_time
+ if dttype is int or dttype is float:
tt = time.localtime(date_time)
- elif dttype is type(()):
+ else:
tt = date_time
- elif dttype is type(""):
- return date_time # Assume in correct format
- else: raise ValueError
dt = time.strftime("%d-%b-%Y %H:%M:%S", tt)
if dt[0] == '0':
@@ -1085,7 +1084,7 @@
zone = -time.altzone
else:
zone = -time.timezone
- return '"' + dt + " %+02d%02d" % divmod(zone/60,
60) + '"'
+ return '"' + dt + " %+03d%02d" % divmod(zone/60,
60) + '"'
----------------------------------------------------------------------
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=499169&group_id=5470