Commit 0d2ffcec authored by Kevin Deldycke's avatar Kevin Deldycke

Set a default output format.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@6045 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 471ff93e
......@@ -643,6 +643,41 @@ class PatchedDateTimeWidget(DateTimeWidget):
else:
return date_result
def render_view(self, field, value):
if value is None:
return ''
use_ampm = field.get_value('ampm_time_style')
year = "%04d" % value.year()
month = "%02d" % value.month()
day = "%02d" % value.day()
if use_ampm:
hour = "%02d" % value.h_12()
else:
hour = "%02d" % value.hour()
minute = "%02d" % value.minute()
ampm = value.ampm()
order = field.get_value('input_order')
if order == 'ymd':
output = [year, month, day]
elif order == 'dmy':
output = [day, month, year]
elif order == 'mdy':
output = [month, day, year]
else:
output = [year, month, day]
date_result = string.join(output, field.get_value('date_separator'))
if not field.get_value('date_only'):
time_result = hour + field.get_value('time_separator') + minute
if use_ampm:
time_result += ' ' + ampm
return date_result + '   ' + time_result
else:
return date_result
DateTimeField.widget = PatchedDateTimeWidget()
from Products.Formulator.Validator import DateTimeValidator, ValidationError, DateTime
......
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