Reviewers: ,
Please review this at http://codereview.tryton.org/237003/
Affected files:
M tryton/common/common.py
M tryton/gui/window/view_form/view/form_gtk/calendar.py
M tryton/gui/window/view_form/view/list_gtk/parser.py
Index: tryton/common/common.py
===================================================================
--- a/tryton/common/common.py
+++ b/tryton/common/common.py
@@ -1461,11 +1461,17 @@
'dict': dict,
}}, 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)
Index: tryton/gui/window/view_form/view/form_gtk/calendar.py
===================================================================
--- a/tryton/gui/window/view_form/view/form_gtk/calendar.py
+++ b/tryton/gui/window/view_form/view/form_gtk/calendar.py
@@ -8,7 +8,7 @@
from interface import WidgetInterface
import tryton.rpc as rpc
from tryton.common import DT_FORMAT, DHM_FORMAT, HM_FORMAT, message, \
- TRYTON_ICON, timezoned_date
+ TRYTON_ICON, timezoned_date, untimezoned_date
from tryton.common import date_widget, Tooltips, datetime_strftime, \
get_toplevel_window
from tryton.translate import date_format
@@ -192,7 +192,7 @@
date = datetime.datetime(*time.strptime(value,
self.format)[:6])
except ValueError:
return False
- date = timezoned_date(date)
+ date = untimezoned_date(date)
return datetime_strftime(date, DHM_FORMAT)
def set_value(self, record, field):
Index: tryton/gui/window/view_form/view/list_gtk/parser.py
===================================================================
--- a/tryton/gui/window/view_form/view/list_gtk/parser.py
+++ b/tryton/gui/window/view_form/view/list_gtk/parser.py
@@ -437,7 +437,7 @@
return ''
date = datetime.datetime(*time.strptime(value,
self.server_format)[:6])
- date = common.timezoned_date(date)
+ date = common.untimezoned_date(date)
return common.datetime_strftime(date, self.display_format)
def value_from_text(self, record, text, callback=None):
--
[email protected] mailing list