Commit 42224db7 authored by Yoshinori Okuji's avatar Yoshinori Okuji

Slightly change it back to the previous implementation, as the naive...

Slightly change it back to the previous implementation, as the naive implementation does not work well when neither UTC nor local time is used. It is difficult to address this problem appropriately on Zope 2.8, as DateTime does not support pytz in this version, thus it cannot interpret arbitrary timezone names.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@39462 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent b016df0f
...@@ -130,14 +130,7 @@ class PeriodicityMixin: ...@@ -130,14 +130,7 @@ class PeriodicityMixin:
return date.month() in periodicity_month_list return date.month() in periodicity_month_list
def _getTimezone(self, date): def _getTimezone(self, date):
# This method provides an utility to deal with a timezone as a workaround. return date.timezone()
# This is necessary because DateTime does not respect the real timezone
# such as Europe/Paris, but only stores a difference from GMT such as
# GMT+1, thus it does not work nicely with daylight savings.
if date.tzoffset() == 0:
# Looks like using GMT.
return date.timezone()
return None
def _getNextMonth(self, date, timezone): def _getNextMonth(self, date, timezone):
year = date.year() year = date.year()
...@@ -221,15 +214,17 @@ class PeriodicityMixin: ...@@ -221,15 +214,17 @@ class PeriodicityMixin:
elif not (self._validateDay(next_start_date) and elif not (self._validateDay(next_start_date) and
self._validateWeek(next_start_date)): self._validateWeek(next_start_date)):
next_start_date = self._getNextDay(next_start_date, timezone) next_start_date = self._getNextDay(next_start_date, timezone)
elif not self._validateMinute(next_start_date, previous_date):
next_start_date = self._getNextMinute(next_start_date, timezone)
elif not self._validateHour(next_start_date): elif not self._validateHour(next_start_date):
next_start_date = self._getNextHour(next_start_date, timezone) next_start_date = self._getNextHour(next_start_date, timezone)
elif not self._validateMinute(next_start_date, previous_date):
next_start_date = self._getNextMinute(next_start_date, timezone)
else: else:
parts = list(next_start_date.parts()) parts = list(next_start_date.parts())
parts[5] = previous_date.second() # XXX keep old behaviour parts[5] = previous_date.second() # XXX keep old behaviour
parts[6] = timezone next_start_date = DateTime(*parts)
return DateTime(*parts) if timezone is not None:
next_start_date = next_start_date.toZone(timezone)
return next_start_date
# XXX May be we should create a Date class for following methods ??? # XXX May be we should create a Date class for following methods ???
security.declareProtected(Permissions.AccessContentsInformation, 'getWeekDayList') security.declareProtected(Permissions.AccessContentsInformation, 'getWeekDayList')
...@@ -606,7 +601,7 @@ Alarm Tool Node: %s ...@@ -606,7 +601,7 @@ Alarm Tool Node: %s
alarm_date = self.getAlarmDate() alarm_date = self.getAlarmDate()
if alarm_date is not None: if alarm_date is not None:
if current_date is None: if current_date is None:
# This is usefull to set the current date as parameter for # This is useful to set the current date as parameter for
# unit testing, by default it should be now # unit testing, by default it should be now
current_date = DateTime() current_date = DateTime()
alarm_date = self.getNextPeriodicalDate(current_date, alarm_date = self.getNextPeriodicalDate(current_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