faces: Fix 24-hour and end-at-midnight timespans
In cases where a working day either: - Spans 24 hours or - ends at midnight the time span calculation code incorrectly calculates the time of that day, either stating that the day is 0 minutes long, or worse, is negative. The following patch addresses this. Non-working days are specified using the Python 'None', or 'False' values, rather than specifying the same start and end time, as the latter will now be interpreted as a 24-hour period. bzr revid: me@vk4msl.yi.org-20120323052146-vosvz50lg12n7e1i
This commit is contained in:
@@ -895,7 +895,16 @@ class Calendar(object):
|
||||
def _recalc_working_time(self):
|
||||
def slot_sum_time(day):
|
||||
slots = self.working_times.get(day, DEFAULT_WORKING_DAYS[day])
|
||||
return sum(map(lambda slot: slot[1] - slot[0], slots))
|
||||
def time_diff(times):
|
||||
(start, end) = times
|
||||
if end == start:
|
||||
return 24*60 # 24 hours
|
||||
|
||||
diff = end - start
|
||||
if end < start:
|
||||
diff += (24*60)
|
||||
return diff
|
||||
return sum(map(time_diff, slots))
|
||||
|
||||
self.day_times = map(slot_sum_time, range(0, 7))
|
||||
self.week_time = sum(self.day_times)
|
||||
|
||||
Reference in New Issue
Block a user