Tutorial :Parsing dates from free-text input in Python


I'm about to start working on a simple calendar app for a website I'm working on (using Django, but that fact's probably not relevant).

I'd like users to be able to enter when an event is in a text box like this:

  • Every Sunday evening at 7pm
  • Next Friday
  • Tuesday 1st Dec 2009

and have my application begin to make some guesses as to when they mean. I don't need it to promise to be right, just to be able to present the users with some guesses as to what they mean. Is there a Python library that does some of this? Bonus points if it's extensible to match more formats.

I don't care too much about timezones - for the purposes of my application it's safe to assume any times are in whatever timezone London happens to be in. I'll work that out once I've got some kind of yyyymmddhhiiss representation (or similar).

Apologies if there's a duplicate I've missed - I did have a look.


There is http://code.google.com/p/parsedatetime/


I proposed a pyparsing solution to this question, which seems similar to yours.

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »