How to compare to time strings?
Emile van Sebille
emile at fenx.com
Sat Jan 19 17:20:18 EST 2002
"A" <printers at sendme.cz> wrote in message
news:mailman.1011477641.28039.python-list at python.org...
> Hello,
> I have two time strings like
> Mon, 31 Dec 2001 15
> and
> Sat, 19 Jan 2002 21
>
> How can I compare them and find out that
> Mon, 31 Dec 2001 15
> is before
> Sat, 19 Jan 2002 21
> ?
>
> I can not use
> strptime function , to convert it first,because I use windows and
> there is not that function.
Get a copy of Marc Andre's mxDateTime from
http://www.egenix.com/files/python/eGenix-mx-Extensions.html#Download-mx
BASE
Then you can do:
>>> from mx import DateTime
>>> print DateTime.DateTimeFrom('Mon, 31 Dec 2001 15') -
DateTime.DateTimeFrom('
Sat, 19 Jan 2002 21')
-19:00:00:00.00
It doesn't appear to do anything with the (assumed) hour part though.
HTH,
--
Emile van Sebille
emile at fenx.com
---------
More information about the Python-list
mailing list