parse dates

Eddie Corns eddie at holyrood.ed.ac.uk
Mon Jun 2 10:26:59 EDT 2008


brechmos <brechmos at gmail.com> writes:

>Hi,

>I have been using PHP the last while and in particular strtotime.
>What I want to replicate is finding the second or fourth Monday of the
>next month.  In PHP with strtotime it is easy (strtotime("second
>Monday", strtotime("next month"), but I can't find an easy way to do
>it in Python.  I have seen DateUtil, but it seems to be able to do
>only the simpler parsing (could be wrong).

>Any other ideas?

http://code-bear.com/code/parsedatetime/

>>> import parsedatetime.parsedatetime as pdt
>>> p = pdt.Calendar()
>>> p.parse('next month')
((2008, 7, 1, 9, 0, 0, 1, 183, -1), 1)

Eddie



More information about the Python-list mailing list