formatted 'time' data in calculations
Stephen Chapman
schap at offenbachers.com
Wed Jan 7 12:45:12 EST 2009
Here is how I have done adjustments to time in the past. This is mostly
Date related but it may help
today = datetime.date.today()
wkdiff = datetime.timedelta(weeks=1)
daydiff = datetime.timedelta(days=1)
startdate=(today-wkdiff)-daydiff
this will subtract 1 week and 1 day from today.
Stephen
Ross wrote:
> There seems to be no shortage of information around on how to use the
> time module, for example to use time.ctime() and push it into strftime
> and get something nice out the other side, but I haven't found
> anything helpful in going the other way.
>
> That is, given some formatted text describing times - is there
> something that makes it easy to calculate time differences, or do I
> have to index my way through the string pulling out characters,
> converting to integers etc...
>
> Data is formatted:
>
> t1 = 09:12:10
> t2 = 11:22:14
>
> I want to calculate tdiff = t2-t1
>
> Any suggestions? (Thanks for anything you can offer)
>
> -Ross
> --
> http://mail.python.org/mailman/listinfo/python-list
>
>
More information about the Python-list
mailing list