1 2 3 4 5 6 7 8 9 10 | def getHours(self):
"""returns floating point hours rounded up to the nearest quarter hour"""
td = self.end_time - self.start_time
hours = td.seconds // 3600
minutes = (td.seconds % 3600) // 60
dec = (float(minutes) / 60)
quarter = dec // 0.25
if ((dec % 0.25) > 0):
quarter += 0.25
return hours + quarter
|
More like this
- SplitTimeField by theju 5 years, 3 months ago
- Custom model field for mysql time type. by xuqingkuang 3 years, 7 months ago
- Querying datetime aware objects in your local timezone by jayliew 12 months ago
- Quantize decimal template filter by bl4th3rsk1t3 4 years ago
- Time ranges like 7-9 p.m. by sgb 5 years, 4 months ago
Comments