Wednesday, April 14, 2010

A date parser from python dateutil library

Sometime you need to extract date form a string, and that is actually pretty hard to do even on python. On the other hand, there is dateutils, a python library which you can install using easy_install. The library is pretty nifty, and have many component, but now i concentrate on the date parser

Start by 
from dateutil.parser import *

lets have fun, after the import, we should have the parser imported


You should get the date of next monday as python datetime.datetime object.

parse('14th of april')
parse('14th of april 3pm')

you should get a datetime.datetime object of the date, 

For python programmer, check it out, it is pretty useful.

No comments:

Post a Comment