Reviewers: ,
Please review this at http://codereview.tryton.org/238001/ Affected files: M tryton/common/common.py M tryton/gui/window/view_form/model/field.py Index: tryton/common/common.py =================================================================== --- a/tryton/common/common.py +++ b/tryton/common/common.py @@ -1445,16 +1445,22 @@ }}, data) -def timezoned_date(date): - if pytz and rpc.CONTEXT.get('timezone'): +def timezoned_date(date, reverse=False): + if pytz and rpc.CONTEXT.get('timezone') and rpc.TIMEZONE: lzone = pytz.timezone(rpc.CONTEXT['timezone']) szone = pytz.timezone(rpc.TIMEZONE) + if reverse: + lzone, szone = szone, lzone sdt = szone.localize(date, is_dst=True) ldt = sdt.astimezone(lzone) date = ldt return date +def untimezoned_date(date): + return timezoned_date(date, reverse=True) + + def humanize(size): for x in ('bytes', 'KB', 'MB', 'GB', 'TB', 'PB'): if size < 1000: Index: tryton/gui/window/view_form/model/field.py =================================================================== --- a/tryton/gui/window/view_form/model/field.py +++ b/tryton/gui/window/view_form/model/field.py @@ -214,7 +214,7 @@ try: value = datetime.datetime(*time.strptime(value, date_format() + ' ' + HM_FORMAT)[:6]) - value = common.timezoned_date(value) + value = common.untimezoned_date(value) except ValueError: value = self._default super(DateTimeField, self).set_client(record, value, -- [email protected] mailing list
