Commit 3b6591be authored by Nicolas Delaby's avatar Nicolas Delaby

keep the same timezone as input

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@27520 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent afbd18a0
# -*- coding: utf-8 -*-
############################################################################# #############################################################################
# #
# Copyright (c) 2002 Nexedi SARL and Contributors. All Rights Reserved. # Copyright (c) 2002 Nexedi SARL and Contributors. All Rights Reserved.
...@@ -31,6 +32,7 @@ import warnings ...@@ -31,6 +32,7 @@ import warnings
from AccessControl import ModuleSecurityInfo from AccessControl import ModuleSecurityInfo
from DateTime import DateTime from DateTime import DateTime
from datetime import datetime from datetime import datetime
from string import zfill
from zLOG import LOG from zLOG import LOG
security = ModuleSecurityInfo('Products.ERP5Type.DateUtils') security = ModuleSecurityInfo('Products.ERP5Type.DateUtils')
...@@ -501,16 +503,20 @@ def atTheEndOfPeriod(date, period): ...@@ -501,16 +503,20 @@ def atTheEndOfPeriod(date, period):
2000/01/15, month => 2000/02/01 2000/01/15, month => 2000/02/01
2000/01/18, week => 2000/01/24 2000/01/18, week => 2000/01/24
2000/01/20, day => 2000/01/21 2000/01/20, day => 2000/01/21
If timezone is Universal, strftime('%Z') return empty string
and TimeZone is replaced by local zone,
so date formating is manualy rendered.
XXXSunday is hardcoded
""" """
if period == 'year': if period == 'year':
end = addToDate(DateTime(date.strftime('%Y/01/01 00:00:00')), **{period:1}) end = addToDate(DateTime('%s/01/01 00:00:00 %s' % (date.year(), date.timezone())), **{period:1})
elif period == 'month': elif period == 'month':
end = addToDate(DateTime(date.strftime('%Y/%m/01 00:00:00')), **{period:1}) end = addToDate(DateTime('%s/%s/01 00:00:00 %s' % (date.year(), zfill(date.month(), 2), date.timezone())), **{period:1})
elif period == 'day': elif period == 'day':
end = addToDate(DateTime(date.strftime('%Y/%m/%d 00:00:00')), **{period:1}) end = addToDate(DateTime('%s/%s/%s 00:00:00 %s' % (date.year(), zfill(date.month(), 2), zfill(date.day(), 2), date.timezone())), **{period:1})
elif period == 'week': elif period == 'week':
day_of_week = date.strftime('%A') day_of_week = date.strftime('%A')
end = DateTime(date.strftime('%Y/%m/%d 00:00:00')) end = DateTime('%s/%s/%s 00:00:00 %s' % (date.year(), zfill(date.month(), 2), zfill(date.day(), 2), date.timezone()))
while day_of_week != 'Sunday': while day_of_week != 'Sunday':
end = addToDate(end, day=1) end = addToDate(end, day=1)
day_of_week = end.strftime('%A') day_of_week = end.strftime('%A')
......
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