get date from email
Thomas Guettler
hv at tbz-pariv.de
Thu Dec 1 05:25:02 EST 2011
More information about the Python-list mailing list
Thu Dec 1 05:25:02 EST 2011
- Previous message (by thread): unpack('>f', b'\x00\x01\x00\x00')
- Next message (by thread): order independent hash?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Hi,
up to now I use this code to parse date values from emails:
msg=email.message_from_file(open(file_name))
date=None
date_str=msg.get('date')
if date_str:
date_tuple=email.utils.parsedate_tz(date_str)
if date_tuple:
date=datetime.datetime.fromtimestamp(email.utils.mktime_tz(date_tuple))
if date:
... # valid date found
Somehow this looks too complicated. Any chance to integrate the datetime module into the email module?
related: http://stackoverflow.com/questions/1790795/python-parsing-date-with-timezone-from-an-email
--
Thomas Guettler, http://www.thomas-guettler.de/
E-Mail: guettli (*) thomas-guettler + de
- Previous message (by thread): unpack('>f', b'\x00\x01\x00\x00')
- Next message (by thread): order independent hash?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list