Commit 93f432d5 authored by Romain Courteaud's avatar Romain Courteaud

Improve time precision by using the addToDate method

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@14206 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent d82ca112
...@@ -143,7 +143,7 @@ class PresencePeriod(Movement, PeriodicityMixin): ...@@ -143,7 +143,7 @@ class PresencePeriod(Movement, PeriodicityMixin):
stop_date = self.getStopDate(start_date) stop_date = self.getStopDate(start_date)
periodicity_stop_date = self.getPeriodicityStopDate( periodicity_stop_date = self.getPeriodicityStopDate(
start_date) start_date)
duration = stop_date - start_date second_duration = int(stop_date) - int(start_date)
# First date has to respect the periodicity config # First date has to respect the periodicity config
next_start_date = self.getNextPeriodicalDate(start_date-1) next_start_date = self.getNextPeriodicalDate(start_date-1)
while (next_start_date is not None) and \ while (next_start_date is not None) and \
...@@ -163,7 +163,8 @@ class PresencePeriod(Movement, PeriodicityMixin): ...@@ -163,7 +163,8 @@ class PresencePeriod(Movement, PeriodicityMixin):
(current_exception_date < next_start_date.Date()): (current_exception_date < next_start_date.Date()):
# SQL method don't like iterator # SQL method don't like iterator
# yield (next_start_date, next_start_date+duration) # yield (next_start_date, next_start_date+duration)
result.append([next_start_date, next_start_date+duration]) result.append([next_start_date,
addToDate(next_start_date, second=second_duration)])
# Update the next exception date # Update the next exception date
if len(exception_date_list) != 0: if len(exception_date_list) != 0:
current_exception_date = exception_date_list.pop(0).Date() current_exception_date = exception_date_list.pop(0).Date()
...@@ -172,7 +173,8 @@ class PresencePeriod(Movement, PeriodicityMixin): ...@@ -172,7 +173,8 @@ class PresencePeriod(Movement, PeriodicityMixin):
else: else:
# SQL method don't like iterator # SQL method don't like iterator
# yield (next_start_date, next_start_date+duration) # yield (next_start_date, next_start_date+duration)
result.append([next_start_date, next_start_date+duration]) result.append([next_start_date,
addToDate(next_start_date, second=second_duration)])
next_start_date = self.getNextPeriodicalDate(next_start_date) next_start_date = self.getNextPeriodicalDate(next_start_date)
return result return result
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment