tags:

views:

234

answers:

2

I'm looking for a Python module that would take an arbitrary block of text, search it for something that looks like a date string, and build a DateTime object out of it. Something like Date::Extract in Perl

Thank you in advance.

+9  A: 

The nearest equivalent is probably the dateutil module. Usage is:

>>> from dateutil.parser import parse
>>> parse("Wed, Nov 12")
datetime.datetime(2008, 11, 12, 0, 0)

Using the fuzzy parameter should ignore extraneous text. ie

>>> parse("the date was the 1st of December 2006 2:30pm", fuzzy=True)
datetime.datetime(2006, 12, 1, 14, 30)
Brian
+5  A: 

Why no give parsedatetime a try?

Ber