Commit 544c68e0 authored by Jérome Perrin's avatar Jérome Perrin

Fix timezone problems with formprintout

When pusing to for_testrunner_1 branch, we often have this failure on testFormPrintoutAsODT:

```
======================================================================
FAIL: test_field_replacement_with_variable (testFormPrintoutAsODT.TestFormPrintoutAsODT)
test variables replacement in ODT documents.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/srv/slapgrid/slappart9/srv/testnode/zl/soft/4a13de8a0fdf926ddebab0387de0dc5e/parts/erp5/Products/ERP5OOo/tests/testFormPrintoutAsODT.py", line 1252, in test_field_replacement_with_variable
    self.assertEqual(node.text, value.strftime('%d/%m/%Y %H:%M:%S'))
AssertionError: '06/12/2010 11:33:15' != '06/12/2010 11:24:15'
```

After some investigation, turned out that:
* tests where always failing when running by `COMP-2544-3Nodes-ERP5PROJECT2` testnode
* This machine uses `SystemV/CST6CDT` as timezone
* the test fails in the same way when running locally with `TZ=SystemV/CST6CDT`

I belive this fixes, I tried running under `SystemV/CST6CDT`, `UTC` and `Europe/Paris`  TZ and it passes for all cases. 

/reviewed-on nexedi/erp5!174
parents d4fc3821 5bb2eeca
...@@ -1249,7 +1249,7 @@ return [] ...@@ -1249,7 +1249,7 @@ return []
self.assertEqual(node.get('{%s}value' % nsmap['office']), str(value)) self.assertEqual(node.get('{%s}value' % nsmap['office']), str(value))
elif klass == 'DateTimeField': elif klass == 'DateTimeField':
self.assertEqual(node.get('{%s}value-type' % nsmap['office']), 'date') self.assertEqual(node.get('{%s}value-type' % nsmap['office']), 'date')
self.assertEqual(node.text, value.strftime('%d/%m/%Y %H:%M:%S')) self.assertEqual(node.text, '06/12/2010 23:24:15')
elif klass == 'CheckBoxField': elif klass == 'CheckBoxField':
self.assertEqual(node.get('{%s}value-type' % nsmap['office']), self.assertEqual(node.get('{%s}value-type' % nsmap['office']),
'boolean') 'boolean')
......
...@@ -1629,8 +1629,7 @@ class DateTimeWidget(Widget): ...@@ -1629,8 +1629,7 @@ class DateTimeWidget(Widget):
# default offset is 30/12/1899 # default offset is 30/12/1899
number_of_second_in_day = 86400 #24 * 60 * 60 number_of_second_in_day = 86400 #24 * 60 * 60
timestamp = float(value) timestamp = float(value)
# XXX Works only if the timezone is the same in OpenOffice ooo_offset_timestamp = float(DateTime(1899, 12, 30, 0, 0, 0, value.timezone()))
ooo_offset_timestamp = float(DateTime(1899, 12, 30))
days_value = (timestamp - ooo_offset_timestamp) / number_of_second_in_day days_value = (timestamp - ooo_offset_timestamp) / number_of_second_in_day
attr_dict['{%s}formula' % TEXT_URI] = 'ooow:%f' % days_value attr_dict['{%s}formula' % TEXT_URI] = 'ooow:%f' % days_value
text_node.attrib.update(attr_dict) text_node.attrib.update(attr_dict)
......
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