Just multiply the hour
and minute
attributes, divide the microsecond
attribute and add it all together:
>>> (t.hour * 3600) + (t.minute * 60) + t.second + (t.microsecond / 1000000.0)
39725.110521
You cannot use datetime.time.min
because datetime.time
objects don't support subtraction, unfortunately.
You could produce a datetime.datetime
object by combining the time plus datetime.date.min
(earliest supported date), then subtract datetime.datetime.min
(earliest supported date and time), but that's long-winded too:
>>> datetime.datetime.combine(datetime.date.min, t) - datetime.datetime.min
datetime.timedelta(0, 39725, 110521)
>>> (datetime.datetime.combine(datetime.date.min, t) - datetime.datetime.min).total_seconds
39725.110521