Natural Language Date Processing.
John McMonagle
johnmc at velseis.com.au
Thu Feb 9 17:52:36 EST 2006
On Thu, 2006-02-09 at 09:47 +0100, Michael Amrhein wrote:
> Andrew Gwozdziewycz schrieb:
> >> You may take a look at http://labix.org/python-dateutil
> >> Have fun
> >> Michael
> >>
> >
> > Looks like it does a good job parsing dates, but doesn't seem to do
> > english dates. I found a javascript implementation of a few functions
> > that will probably be relatively easy to port to python. Whether or
> > not it'll perform well is another story... Thanks for the help.
> >
> > --
> > Andrew Gwozdziewycz <apgwoz at gmail.com>
> > http://ihadagreatview.org
> > http://plasticandroid.org
>
> >>>from dateutil.parser import parse
> >>>parse("April 16th, 2003")
> datetime.datetime(2003, 4, 16, 0, 0)
> >>>parse("4/16/2003")
> datetime.datetime(2003, 4, 16, 0, 0)
>
> Aren't these "english dates"?
I suspect the OP is referring to "english dates" as non-US format - to
follow the international convention (DD/MM/YYYY).
You can use the dayfirst parameter to the parse function to always
assume international date format:
US Format:
>>> parse("10/12/2004")
datetime.datetime(2004, 10, 12, 0, 0)
International format:
>>> parse("10/12/2004", dayfirst=True)
datetime.datetime(2004, 12, 10, 0, 0)
John
--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
More information about the Python-list
mailing list