Hey Dick, don't know if anyone actually answered your original question.
>IOW, is there an easier way to calculate the time difference between the
>time now, say 08:51 and say, tomorrow at 03:45, to take an example of the
>most difficult case?
So, you need two datetime.datetime objects.
>>>now = datetime.datetime(year, month, day, hours, minutes, seconds)
>>>now = datetime.datetime(2004, 12, 7*, 8*, 51, 00)
>>> later= datetime.datetime(2004, 12, 8*, 3*, 45, 00)
*Can't start with zero. Must be 8 not 08
>>> difference = later - now
>>> print difference
18:54:00
>>> type(difference)
<type 'datetime.timedelta'>
>>> timeList=str(difference).split(":")
>>> print timeList
['18', '54', '00']
>>> timeinSecs=(int(timeList[0])*3600)+(int(timeList[1])*60)+int(timeList[2])
>>> print timeinSecs
68040
Now, to check if that's right...
>>> timeChange=datetime.timedelta(seconds=68040)
>>> checkVal=now + timeChange
>>> print checkVal
2004-12-08 03:45:00
Looks good to me.
So, to summarise the code part -
now = datetime.datetime(2004, 12, 7, 8, 51, 00)
later= datetime.datetime(2004, 12, 8, 3, 45, 00)
difference = later - now
timeList=str(difference).split(":")
timeinSecs=(int(timeList[0])*3600)+(int(timeList[1])*60)+int(timeList[2])
And that's the easier way to find the difference between two times in seconds.
HTH
Liam Clarke
P.S. If you're interested, here's a 20 line alarm clock I wrote
because my one broke this morning.
http://www.rafb.net/paste/results/ctOH1T36.html
On Mon, 06 Dec 2004 02:15:55 -0800, Dick Moores <[EMAIL PROTECTED]> wrote:
> Hey, no problem. And thanks again for your help.
>
> Dick
>
> Liam Clarke wrote at 02:05 12/6/2004:
> >Whoops, sorry. <embarrassed>
>
>
--
'There is only one basic human right, and that is to do as you damn well please.
And with it comes the only basic human duty, to take the consequences.
--
'There is only one basic human right, and that is to do as you damn well please.
And with it comes the only basic human duty, to take the consequences.
_______________________________________________
Tutor maillist - [EMAIL PROTECTED]
http://mail.python.org/mailman/listinfo/tutor