[Tutor] RE: How to compare to time strings?

Mark McEahern marklists@mceahern.com
Sat, 19 Jan 2002 14:10:03 -0800


Short answer:  Use mx.DateTime from egenix:

  http://www.egenix.com/files/python/eGenix-mx-Extensions.html#mxBASE

Here's sample code, once you've installed that:

$ python
>>> s1 = "Mon, 31 Dec 2001 15"
>>> import mx.DateTime
>>> d1 = mx.DateTime.DateFrom(s1)
>>> print d1
2001-12-31 00:00:00.00
>>> s2 = "Sat, 19 Jan 2002 21"
>>> d2 = mx.DateTime.DateFrom(s2)
>>> print (d2 > d1)
1

// mark