Commit 7a570814 authored by Aurel's avatar Aurel

add support for minutes periodicity


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@7842 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 726553a1
...@@ -93,6 +93,19 @@ class Periodicity(Base): ...@@ -93,6 +93,19 @@ class Periodicity(Base):
if next_start_date > current_date: if next_start_date > current_date:
return return
def validateMinute(self,date, previous_date):
periodicity_minute_frequency = self.getPeriodicityMinuteFrequency()
periodicity_minute_list = self.getPeriodicityMinuteList()
if periodicity_minute_frequency is None and periodicity_minute_list in ([],None,()):
# in this case, we may want to have an periodicity every hour based on the start date
# without defining anything about minutes periodicity, so we compare with
# minutes with the one defined in the previous alarm date
return (date.minute() == previous_date.minute())
if periodicity_minute_frequency not in ('',None):
return (date.minute() % periodicity_minute_frequency) == 0
elif len(periodicity_minute_list)>0:
return date.minute() in periodicity_minute_list
def validateHour(self,date): def validateHour(self,date):
periodicity_hour_frequency = self.getPeriodicityHourFrequency() periodicity_hour_frequency = self.getPeriodicityHourFrequency()
periodicity_hour_list = self.getPeriodicityHourList() periodicity_hour_list = self.getPeriodicityHourList()
...@@ -141,14 +154,15 @@ class Periodicity(Base): ...@@ -141,14 +154,15 @@ class Periodicity(Base):
elif len(periodicity_month_list)>0: elif len(periodicity_month_list)>0:
return date.month() in periodicity_month_list return date.month() in periodicity_month_list
next_start_date = addToDate(next_start_date,hour=1) previous_date = next_start_date
while not( next_start_date >= current_date \ next_start_date = addToDate(next_start_date,minute=1)
while not(next_start_date >= current_date \
and validateMinute(self,next_start_date, previous_date) \
and validateHour(self,next_start_date) \ and validateHour(self,next_start_date) \
and validateDay(self,next_start_date) \ and validateDay(self,next_start_date) \
and validateWeek(self,next_start_date) \ and validateWeek(self,next_start_date) \
and validateMonth(self,next_start_date)): and validateMonth(self,next_start_date)):
next_start_date = addToDate(next_start_date,hour=1) next_start_date = addToDate(next_start_date,minute=1)
self.setAlarmDate(next_start_date) self.setAlarmDate(next_start_date)
......
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