◐ Shell
clean mode source ↗

Message 53725 - Python tracker

It would be good to have a simply way to convert
between datetime objects and RFC2822 style strings.
From string to datetime is easy with
datetime.datetime(*email.Utils.parsedate(m)[:7]) (but
this drops the timezone), but the other direction seems
impossible. email.Utils.formatdate takes a timestamp
argument, but AFAICT there's no way to get a timestamp
out of a datetime object.

Of course the best solution (ignoring backwards
compatibility) would be for parsedate und formatdate to
return/accept datetime objects or for datetime to have
the appropriate methods.