Commit 9781d567 authored by Jérome Perrin's avatar Jérome Perrin

ODS Style: use an intermediate script to format the date

This script add support for dates < 1900
parent 27231e59
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string encoding="cdata"><![CDATA[
try:\n
return date.strftime(\'%Y-%m-%dT%H:%M:%S\')\n
except ValueError: # *** ValueError: year=XXX is before 1900; the datetime strftime() methods require year >= 1900\n
return "%04d-%02d-%02dT%02d:%02d:%02d" % (date.year(), date.month(), date.day(), date.hour(), date.minute(), date.second())\n
]]></string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>date</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>ERP5Site_formatDateForODF</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -204,7 +204,7 @@
<tal:block tal:condition="python: isinstance(value, DateTime)">\n
<tal:block tal:define="field python: editable_fields.get(column_id, None);">\n
<tal:block tal:condition="python: field is None">\n
<table:table-cell tal:attributes="office:date-value python: value.strftime(\'%Y-%m-%dT%H:%M:%S\');\n
<table:table-cell tal:attributes="office:date-value python: context.ERP5Site_formatDateForODF(value);\n
table:style-name string:${style_prefix}date;"\n
table:style-name="date"\n
office:value-type="date">\n
......@@ -214,7 +214,7 @@
<tal:block tal:condition="python: field is not None">\n
<tal:block tal:condition="python:field.meta_type==\'DateTimeField\' or (field.meta_type == \'ProxyField\' and field.getRecursiveTemplateField().meta_type == \'DateTimeField\')">\n
<tal:block tal:condition="python:field.get_value(\'date_only\')">\n
<table:table-cell tal:attributes="office:date-value python: value.strftime(\'%Y-%m-%dT%H:%M:%S\');\n
<table:table-cell tal:attributes="office:date-value python: context.ERP5Site_formatDateForODF(value);\n
table:style-name string:${style_prefix}date;"\n
table:style-name="date"\n
office:value-type="date">\n
......@@ -222,7 +222,7 @@
</table:table-cell>\n
</tal:block>\n
<tal:block tal:condition="python:field.get_value(\'date_only\')==0">\n
<table:table-cell tal:attributes="office:date-value python: value.strftime(\'%Y-%m-%dT%H:%M:%S\');\n
<table:table-cell tal:attributes="office:date-value python: context.ERP5Site_formatDateForODF(value);\n
table:style-name string:${style_prefix}date_with_time;"\n
table:style-name="date_with_time"\n
office:value-type="date">\n
......
255
\ No newline at end of file
256
\ No newline at end of file
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