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


Groups > comp.lang.python > #16486

get date from email

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!news.musoftware.de!wum.musoftware.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From Thomas Guettler <hv@tbz-pariv.de>
Newsgroups comp.lang.python
Subject get date from email
Date Thu, 01 Dec 2011 11:25:02 +0100
Lines 22
Message-ID <9jp2vuFrg4U1@mid.individual.net> (permalink)
Mime-Version 1.0
Content-Type text/plain; charset=ISO-8859-15
Content-Transfer-Encoding 7bit
X-Trace individual.net n34wPOrSHclydiJG22ByIQZI9YZXFQgiblEgonkTBus3LxNWs=
Cancel-Lock sha1:9Hh+IhUUQ6xtDvmlGBuScQ85FyY=
User-Agent Mozilla/5.0 (X11; U; Linux x86_64; de; rv:1.9.1.16) Gecko/20101125 SUSE/3.0.11 Thunderbird/3.0.11
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:16486

Show key headers only | View raw


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

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

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

csiph-web