[issue11024] imaplib: Time2Internaldate() returns localized strings

Alexander Belopolsky report at bugs.python.org
Sat Jan 29 00:33:23 CET 2011


Alexander Belopolsky <belopolsky at users.sourceforge.net> added the comment:

I would write the formatting code as follows:

('"%2d-%s-%04d %02d:%02d:%02d %+03d%02d"' %
 ((tt[2], _month_names[tt[1]], tt[0]) +
   tt[3:6] + divmod(zone//60, 60)))

The above also assumes that month names are stored in a 1-based array:

_month_names = [None, 'Jan', ...]

Note that %2d format code takes care of space-padding.

If you think the expression that I conjured is too cryptic, get the temporal data from timetuple first with say

y, m, d, H, M, S = tt[:6]

and use named variables in the formatting expression.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue11024>
_______________________________________


More information about the Python-bugs-list mailing list