I have two time objects
`statrt_time` and `end_time`
my code
if self.book_from and self.book_to:
fmt = '%Y-%m-%d %H:%M:%S'
s = datetime.strptime(self.book_from,fmt)
e = datetime.strptime(self.book_to,fmt)
diff = e - s
total_seconds=diff.seconds
time_diff = (total_seconds/3600.0)
no_of_units = (time_diff/4)
if(e<s):
self.units = 0
else:
self.units = math.ceil(no_of_units)
Here, when I subtract the time on the same day, it gives the correct difference. But when the day changes, it does not calculate the difference in the day, but only gives the difference in time. How can I add the difference per day?
source
share