Commit a6b59a54 authored by Romain Courteaud's avatar Romain Courteaud

calendar: use addToDate function to manipulate DateTime.

It allows to create new DateTime with the same timezone.
parent 3c43b7db
......@@ -55,6 +55,7 @@
# automatically set a good start and stop date to make generic code working\n
\n
from DateTime import DateTime\n
from Products.ERP5Type.DateUtils import addToDate\n
time_table_line = state_change["object"]\n
\n
day_of_week = time_table_line.getDayOfWeek()\n
......@@ -63,9 +64,9 @@ if not(None in (day_of_week, quantity)):\n
time_table_line.setPeriodicityWeekDayList([day_of_week])\n
start_date = DateTime("2014/04/01")\n
while start_date.Day() != day_of_week:\n
start_date = start_date + 1\n
start_date = addToDate(start_date, day=1)\n
time_table_line.setStartDate(start_date)\n
stop_date = start_date + 1.0/24*quantity\n
stop_date = addToDate(start_date, hour=quantity)\n
time_table_line.setStopDate(stop_date)\n
# after change, make sure to update group calendars through the usual alarm\n
context.getPortalObject().portal_alarms.update_time_table_end_periodicity.activate(\n
......
......@@ -152,7 +152,7 @@ class PresencePeriod(Movement, PeriodicityMixin):
second_duration = int(stop_date) - int(start_date)
if second_duration > 0:
# First date has to respect the periodicity config
next_start_date = self.getNextPeriodicalDate(start_date-1)
next_start_date = self.getNextPeriodicalDate(addToDate(start_date, day=-1))
while (next_start_date is not None) and \
(next_start_date <= periodicity_stop_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