Re: Convert Military Time to Standard Time?
Posted: Fri Nov 11, 2011 8:42 pm
ckeyes888 wrote:Came across another issue. I have a trigger that turns on the hot tub and calculates
what time the tub will reach the desired temp based on it's current temp.
I simply take the military time and add time to it depending on the current hot tub temp.
Problem is that the new number can be outside the military time spec by going over 59 mins.
e.g. if the military time is 1550 and I add 30 mins it becomes 1580, then when I convert that
using the script above the ready time becomes 3:80 pm.
The problem here, is that this isn't a military time problem. You would have the same issue with standard time.
new_datetime = datetime.datetime.now() + datetime.timedelta (minutes=45)
So convert from 24 hour time to standard, and use the above as a template...