Commit ca125dac authored by Jérome Perrin's avatar Jérome Perrin

Revert "datetime widget : allow definition of a default timezone"

This reverts commit 9668c1a1.

The problem of timezone is more complex.
Since this commit have a side effect of saving and displaying a different date
when Zope runs on a different timezone that what is configured on the field, it
is safer to revert this commit immediately.
parent 839134e3
...@@ -184,6 +184,10 @@ class DateTimeField(ZMIField): ...@@ -184,6 +184,10 @@ class DateTimeField(ZMIField):
if REQUEST.form['subfield_%s_%s' % (key, 'year')]: if REQUEST.form['subfield_%s_%s' % (key, 'year')]:
return None return None
gmt_timezones = [('GMT%s' %zone, 'GMT%s' %zone,) for zone in range(-12, 0)]\
+ [('GMT', 'GMT',),] \
+ [('GMT+%s' %zone, 'GMT+%s' %zone,) for zone in range(1, 13)]
def create_datetime_text_sub_form(): def create_datetime_text_sub_form():
sub_form = BasicForm() sub_form = BasicForm()
...@@ -234,7 +238,7 @@ def create_datetime_text_sub_form(): ...@@ -234,7 +238,7 @@ def create_datetime_text_sub_form():
title = "Timezone", title = "Timezone",
required = 0, required = 0,
default = 'GMT', default = 'GMT',
items = Widget.gmt_timezones, items = gmt_timezones,
size = 1) size = 1)
sub_form.add_fields([hour, minute, ampm, timezone], "time") sub_form.add_fields([hour, minute, ampm, timezone], "time")
return sub_form return sub_form
...@@ -292,7 +296,7 @@ def create_datetime_list_sub_form(): ...@@ -292,7 +296,7 @@ def create_datetime_list_sub_form():
title = "Timezone", title = "Timezone",
required = 0, required = 0,
default = 'GMT', default = 'GMT',
items = Widget.gmt_timezones, items = gmt_timezones,
size = 1) size = 1)
sub_form.add_group("time") sub_form.add_group("time")
......
...@@ -1280,10 +1280,6 @@ class MultiCheckBoxWidget(MultiItemsWidget): ...@@ -1280,10 +1280,6 @@ class MultiCheckBoxWidget(MultiItemsWidget):
MultiCheckBoxWidgetInstance = MultiCheckBoxWidget() MultiCheckBoxWidgetInstance = MultiCheckBoxWidget()
gmt_timezones = [('GMT%s' %zone, 'GMT%s' %zone,) for zone in range(-12, 0)]\
+ [('GMT', 'GMT',),] \
+ [('GMT+%s' %zone, 'GMT+%s' %zone,) for zone in range(1, 13)]
class DateTimeWidget(Widget): class DateTimeWidget(Widget):
""" """
Added support for key in every call to render_sub_field Added support for key in every call to render_sub_field
...@@ -1365,15 +1361,6 @@ class DateTimeWidget(Widget): ...@@ -1365,15 +1361,6 @@ class DateTimeWidget(Widget):
("list", "list")], ("list", "list")],
size=1) size=1)
default_timezone = fields.ListField('default_timezone',
title="Default Timezone",
description=(
"The default timezone display when inputing a new date"),
default="GMT",
items=gmt_timezones,
required=1,
size=1)
input_order = fields.ListField('input_order', input_order = fields.ListField('input_order',
title="Input order", title="Input order",
description=( description=(
...@@ -1401,8 +1388,8 @@ class DateTimeWidget(Widget): ...@@ -1401,8 +1388,8 @@ class DateTimeWidget(Widget):
property_names = Widget.property_names +\ property_names = Widget.property_names +\
['default_now', 'date_separator', 'time_separator', ['default_now', 'date_separator', 'time_separator',
'input_style', 'input_order', 'date_only', 'input_style', 'input_order', 'date_only',
'ampm_time_style', 'timezone_style', 'default_timezone', 'ampm_time_style', 'timezone_style', 'hide_day',
'hide_day', 'hidden_day_is_last_day'] 'hidden_day_is_last_day']
def getInputOrder(self, field): def getInputOrder(self, field):
input_order = field.get_value('input_order') input_order = field.get_value('input_order')
...@@ -1460,7 +1447,7 @@ class DateTimeWidget(Widget): ...@@ -1460,7 +1447,7 @@ class DateTimeWidget(Widget):
hour = None hour = None
minute = None minute = None
ampm = None ampm = None
timezone = field.get_value("default_timezone") timezone = None
if isinstance(value, DateTime): if isinstance(value, DateTime):
year = "%04d" % value.year() year = "%04d" % value.year()
month = "%02d" % value.month() month = "%02d" % value.month()
......
...@@ -280,7 +280,6 @@ class SerializeTestCase(unittest.TestCase): ...@@ -280,7 +280,6 @@ class SerializeTestCase(unittest.TestCase):
request.update(default_values) request.update(default_values)
request.update( {'field_input_style': 'list', request.update( {'field_input_style': 'list',
'field_input_order': 'mdy', 'field_input_order': 'mdy',
'field_default_timezone': 'GMT',
'field_date_only': '', 'field_date_only': '',
'field_css_class': 'test_css', 'field_css_class': 'test_css',
'field_time_separator': '$', 'field_time_separator': '$',
......
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