Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #16486 > unrolled thread

get date from email

Started byThomas Guettler <hv@tbz-pariv.de>
First post2011-12-01 11:25 +0100
Last post2011-12-01 11:25 +0100
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python


Contents

  get date from email Thomas Guettler <hv@tbz-pariv.de> - 2011-12-01 11:25 +0100

#16486 — get date from email

FromThomas Guettler <hv@tbz-pariv.de>
Date2011-12-01 11:25 +0100
Subjectget date from email
Message-ID<9jp2vuFrg4U1@mid.individual.net>
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

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web