Fractional Hours from datetime?
austyn at gmail.com
Mon Jan 11 05:04:18 CET 2010
arizona_utc_offset = -7.00
h = (time.time() / 3600 + arizona_utc_offset) % 24
dt.timetuple() is the day of the week; struct tm_time doesn't
include a sub-second field.
On Jan 10, 10:28 am, "W. eWatson" <wolftra... at invalid.com> wrote:
> Maybe there's a more elegant way to do this. I want to express the
> result of datetime.datetime.now() in fractional hours.
> Here's one way.
> xtup = dt.timetuple()
> h = xtup+xtup/60.0+xtup/3600.00+xtup/10**6
> # now is in fractions of an hour
More information about the Python-list