[Python-bugs-list] [ python-Bugs-665194 ] datetime-RFC2822 roundtripping

SourceForge.net noreply@sourceforge.net
Fri, 10 Jan 2003 21:10:33 -0800


Bugs item #665194, was opened at 2003-01-09 13:24
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=665194&group_id=5470

Category: None
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Walter Dörwald (doerwalter)
Assigned to: Nobody/Anonymous (nobody)
Summary: datetime-RFC2822 roundtripping

Initial Comment:
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.

----------------------------------------------------------------------

>Comment By: Tim Peters (tim_one)
Date: 2003-01-11 00:10

Message:
Logged In: YES 
user_id=31435

You can get a timestamp like so:

>>> time.mktime(datetime.date(2002, 1, 1).timetuple())
1009861200.0
>>>

The dates for which this works depends on the platform 
mktime implementation, though.

BTW, this sounds a lot more like a new feature request 
than a bug!

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=665194&group_id=5470