equal
deleted
inserted
replaced
40 .. autoclass:: cubicweb.web.formfields.BigIntField() |
40 .. autoclass:: cubicweb.web.formfields.BigIntField() |
41 .. autoclass:: cubicweb.web.formfields.FloatField() |
41 .. autoclass:: cubicweb.web.formfields.FloatField() |
42 .. autoclass:: cubicweb.web.formfields.BooleanField() |
42 .. autoclass:: cubicweb.web.formfields.BooleanField() |
43 .. autoclass:: cubicweb.web.formfields.DateField() |
43 .. autoclass:: cubicweb.web.formfields.DateField() |
44 .. autoclass:: cubicweb.web.formfields.DateTimeField() |
44 .. autoclass:: cubicweb.web.formfields.DateTimeField() |
|
45 .. autoclass:: cubicweb.web.formfields.TZDatetimeField() |
45 .. autoclass:: cubicweb.web.formfields.TimeField() |
46 .. autoclass:: cubicweb.web.formfields.TimeField() |
46 .. autoclass:: cubicweb.web.formfields.TimeIntervalField() |
47 .. autoclass:: cubicweb.web.formfields.TimeIntervalField() |
47 |
48 |
48 Compound fields |
49 Compound fields |
49 '''''''''''''''' |
50 '''''''''''''''' |
62 |
63 |
63 """ |
64 """ |
64 __docformat__ = "restructuredtext en" |
65 __docformat__ = "restructuredtext en" |
65 |
66 |
66 from datetime import datetime, timedelta |
67 from datetime import datetime, timedelta |
|
68 |
|
69 import pytz |
67 |
70 |
68 from six import PY2, text_type, string_types |
71 from six import PY2, text_type, string_types |
69 |
72 |
70 from logilab.mtconverter import xml_escape |
73 from logilab.mtconverter import xml_escape |
71 from logilab.common import nullobject |
74 from logilab.common import nullobject |
1011 :class:`~cubicweb.web.formwidgets.JQueryDateTimePicker`. |
1014 :class:`~cubicweb.web.formwidgets.JQueryDateTimePicker`. |
1012 """ |
1015 """ |
1013 widget = fw.JQueryDateTimePicker |
1016 widget = fw.JQueryDateTimePicker |
1014 format_prop = 'ui.datetime-format' |
1017 format_prop = 'ui.datetime-format' |
1015 etype = 'Datetime' |
1018 etype = 'Datetime' |
|
1019 |
|
1020 |
|
1021 class TZDatetimeField(DateTimeField): |
|
1022 """ Use this field to edit a timezone-aware datetime (`TZDatetime` yams |
|
1023 type). Note the posted values are interpreted as UTC, so you may need to |
|
1024 convert them client-side, using some javascript in the corresponding widget. |
|
1025 """ |
|
1026 |
|
1027 def _ensure_correctly_typed(self, form, value): |
|
1028 tz_naive = super(TZDatetimeField, self)._ensure_correctly_typed( |
|
1029 form, value) |
|
1030 return tz_naive.replace(tzinfo=pytz.utc) |
1016 |
1031 |
1017 |
1032 |
1018 class TimeField(DateField): |
1033 class TimeField(DateField): |
1019 """Use this field to edit time (`Time` yams type). |
1034 """Use this field to edit time (`Time` yams type). |
1020 |
1035 |
1265 'Float': FloatField, |
1280 'Float': FloatField, |
1266 'Decimal': StringField, |
1281 'Decimal': StringField, |
1267 |
1282 |
1268 'Date': DateField, |
1283 'Date': DateField, |
1269 'Datetime': DateTimeField, |
1284 'Datetime': DateTimeField, |
1270 'TZDatetime': DateTimeField, |
1285 'TZDatetime': TZDatetimeField, |
1271 'Time': TimeField, |
1286 'Time': TimeField, |
1272 'TZTime': TimeField, |
1287 'TZTime': TimeField, |
1273 'Interval': TimeIntervalField, |
1288 'Interval': TimeIntervalField, |
1274 } |
1289 } |