开发者

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 poin开发者_如何学Cts 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜