Intelligent Date & Time parsing

shakefu at gmail.com shakefu at gmail.com
Fri Mar 7 17:22:07 EST 2008


On Mar 7, 4:10 pm, Mike Driscoll <kyoso... at gmail.com> wrote:
> On Mar 7, 4:08 pm, shak... at gmail.com wrote:
>
> > I'm new to python and I was wondering if there are any intelligent
> > date/time parsing modules out there. I've looked at strptime (or
> > whichever it is) and mxDateTime from the eGenix package. I need
> > something to parse user input for a django app, and it's awesome to be
> > able to write "last monday", "a year ago", or "10pm tuesday" like
> > PHP's strtotime.
>
> > So are there any modules that allow for that kind of parsing?
>
> There's the dateutil module that's a fancy wrapper for the datetime
> module. The author's site has lots of examples as well as the source:
>
> http://labix.org/python-dateutil
>
> I use it quite a bit.
>
> HTH
>
> Mike

So close - I tried it in the interpreter it works great for most
things (like "10pm tuesday") but I'm really hoping for something
that'll work with generics like "tomorrow", "yesterday", "last
tuesday", "next month", etc. Although I know that's pretty language
specific. I was just sort of wishing someone had written it before
me... maybe? Possibly?

Although if I end up writing my own I'll sure use
datetime.parser.parse to get everything left over once you remove
strings like "this saturday". So it helps a little!

Jacob




More information about the Python-list mailing list