imaplib function bug?

Colin Brown cbrown at metservice.com
Fri Sep 24 01:20:03 CEST 2004


The Python 2.3 documentation in imaplib says:
  Internaldate2tuple( datestr)
  Converts an IMAP4 INTERNALDATE string to Coordinated Universal Time.
Returns a time module tuple.

  Time2Internaldate( date_time)
  Converts a time module tuple to an IMAP4 "INTERNALDATE" representation.
Returns a string in the form: "DD-Mmm-YYYY HH:MM:SS +HHMM" (including
double-quotes).
Yet running the following code produces inconsistent results (returning
local not UTC time for Internaldate2tuple):

import imaplib, time
tmtup = time.localtime()
imaptm = imaplib.Time2Internaldate(tmtup)
print 'local_time:',tmtup
print 'local_time:',imaptm
utc = imaplib.Internaldate2tuple('INTERNALDATE '+imaptm)
print 'utc_time  :',utc

C:\>python imapbug.py
local_time: (2004, 9, 24, 10, 52, 59, 4, 268, 0)
local_time: "24-Sep-2004 10:52:59 +1200"
utc_time  : (2004, 9, 24, 10, 52, 59, 4, 268, 0)

Is this a bug?

Colin Brown
PyNZ






More information about the Python-list mailing list