[Erp5-report] r39462 yo - /erp5/trunk/products/ERP5/Document/Alarm.py
nobody at svn.erp5.org
nobody at svn.erp5.org
Fri Oct 22 08:39:45 CEST 2010
Author: yo
Date: Fri Oct 22 08:39:43 2010
New Revision: 39462
URL: http://svn.erp5.org?rev=39462&view=rev
Log:
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.
Modified:
erp5/trunk/products/ERP5/Document/Alarm.py
Modified: erp5/trunk/products/ERP5/Document/Alarm.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/Document/Alarm.py?rev=39462&r1=39461&r2=39462&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/Document/Alarm.py [utf8] (original)
+++ erp5/trunk/products/ERP5/Document/Alarm.py [utf8] Fri Oct 22 08:39:43 2010
@@ -130,14 +130,7 @@ class PeriodicityMixin:
return date.month() in periodicity_month_list
def _getTimezone(self, date):
- # This method provides an utility to deal with a timezone as a workaround.
- # 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
+ return date.timezone()
def _getNextMonth(self, date, timezone):
year = date.year()
@@ -221,15 +214,17 @@ class PeriodicityMixin:
elif not (self._validateDay(next_start_date) and
self._validateWeek(next_start_date)):
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):
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:
parts = list(next_start_date.parts())
parts[5] = previous_date.second() # XXX keep old behaviour
- parts[6] = timezone
- return DateTime(*parts)
+ next_start_date = 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 ???
security.declareProtected(Permissions.AccessContentsInformation, 'getWeekDayList')
@@ -606,7 +601,7 @@ Alarm Tool Node: %s
alarm_date = self.getAlarmDate()
if alarm_date is not 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
current_date = DateTime()
alarm_date = self.getNextPeriodicalDate(current_date,
More information about the Erp5-report
mailing list