plomino / Plomino

Powerful and flexible web-based application builder
33 stars 37 forks source link

DateToString ignore daylight saving #829

Open ivanteoh opened 7 years ago

ivanteoh commented 7 years ago

When I run the unit test for the master branch, the unit test for DateToString fail.

Failure in test test_DateToString (Products.CMFPlomino.tests.test_plominoutils.PlominoUtilsTest)
Traceback (most recent call last):
  File "/Users/ivan/code/buildout.python/parts/opt/lib/python2.7/unittest/case.py", line 329, in run
    testMethod()
  File "/Users/ivan/code/work/PlominoWorkflow/src/Products/CMFPlomino/tests/test_plominoutils.py", line 29, in test_DateToString
    self.assertEqual(utils.DateToString(date), '2013-10-07')
  File "/Users/ivan/code/buildout.python/parts/opt/lib/python2.7/unittest/case.py", line 513, in assertEqual
    assertion_func(first, second, msg=msg)
  File "/Users/ivan/code/buildout.python/parts/opt/lib/python2.7/unittest/case.py", line 506, in _baseAssertEqual
    raise self.failureException(msg)
AssertionError: '2013-10-06' != '2013-10-07'

I run the test from Sydney. Sydney got daylight saving.

Standard Time: Sydney Time Time = GMT+10
Daylight Saving: Sydney Time Time = GMT+11

and toZone(TIMEZONE) seem to ignore the daylight saving when TIMEZONE = os.environ.get('TZ', None) is None and DateToString function is using it.

>>> date.toZone(TIMEZONE)
DateTime('2013/10/06 23:00:00 GMT+10')
>>> date
DateTime('2013/10/07 00:00:00 GMT+11')