You are going about it the wrong way; you just convert the timedelta()
to hours:
def getHoursSince(date):
return int(datetime.timedelta(days=date).total_seconds() // 3600)
which gives:
>>> getHoursSince(1)
24
>>> getHoursSince(1.5)
36
>>> getHoursSince(2)
48
>>> getHoursSince(3)
72
but you can just as well base that off of simple arithmetic:
def getHoursSince(date):
return int(24 * date)