Difference Between Two datetimes

Steve Ferg steve.ferg.bitbucket at gmail.com
Thu Jan 14 13:08:38 EST 2010


> I'd like to start with two dates as strings, as
> "1961/06/16 04:35:25" and "1973/01/18 03:45:50"
> How do I get the strings into a shape that will accommodate a difference?

Pyfdate  http://www.ferg.org/pyfdate/index.html
has a numsplit function that should do the trick:
http://www.ferg.org/pyfdate/tutorial.html#contents_item_14

It splits a string into its numeric parts and return a list containing
the numeric parts converted to ints.

>>> from pyfdate import *
>>> numsplit("2007_10_09")
[2007, 10, 9]
>>> numsplit("2007-10-09T23:45:59")
[2007, 10, 9, 23, 45, 59]
>>> numsplit("2007/10/09 23.45.59")
[2007, 10, 9, 23, 45, 59]







More information about the Python-list mailing list