Commit 61298b26 authored by Jérome Perrin's avatar Jérome Perrin

periodicity: don't depend on DateTime internal attributes

Use calendar module instead. These API depends on current locale, but
we don't set the locale in ERP5, so these remain in English
parent 9d426672
...@@ -27,6 +27,8 @@ ...@@ -27,6 +27,8 @@
# #
############################################################################## ##############################################################################
import calendar
from DateTime import DateTime from DateTime import DateTime
from AccessControl import ClassSecurityInfo from AccessControl import ClassSecurityInfo
from Products.ERP5Type.Globals import InitializeClass from Products.ERP5Type.Globals import InitializeClass
...@@ -228,13 +230,14 @@ class PeriodicityMixin: ...@@ -228,13 +230,14 @@ class PeriodicityMixin:
next_start_date = next_start_date.toZone(timezone) next_start_date = next_start_date.toZone(timezone)
return next_start_date return next_start_date
# XXX May be we should create a Date class for following methods ???
security.declareProtected(Permissions.AccessContentsInformation, 'getWeekDayList') security.declareProtected(Permissions.AccessContentsInformation, 'getWeekDayList')
def getWeekDayList(self): def getWeekDayList(self):
""" """
returns something like ['Sunday','Monday',...] returns something like ['Sunday','Monday',...]
""" """
return DateTime._days return [
calendar.day_name[i]
for i in calendar.Calendar(calendar.SUNDAY).iterweekdays()]
security.declareProtected(Permissions.AccessContentsInformation, 'getWeekDayItemList') security.declareProtected(Permissions.AccessContentsInformation, 'getWeekDayItemList')
def getWeekDayItemList(self): def getWeekDayItemList(self):
...@@ -249,9 +252,10 @@ class PeriodicityMixin: ...@@ -249,9 +252,10 @@ class PeriodicityMixin:
""" """
returns something like [('January', 1), ('February', 2),...] returns something like [('January', 1), ('February', 2),...]
""" """
# DateTime._months return '' as first item # calendar.month_name return '' as first item
return [(Message(domain='erp5_ui', message=DateTime._months[i]), i) \ month_name = list(calendar.month_name)
for i in range(1, len(DateTime._months))] return [(Message(domain='erp5_ui', message=month_name[i]), i) \
for i in range(1, len(month_name))]
security.declareProtected(Permissions.AccessContentsInformation,'getPeriodicityWeekDayList') security.declareProtected(Permissions.AccessContentsInformation,'getPeriodicityWeekDayList')
def getPeriodicityWeekDayList(self): def getPeriodicityWeekDayList(self):
......
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