Edgewall Software

Opened 10 years ago

Last modified 8 years ago

#11563 closed defect

Three datefmt.to_datetime() tests fail when TZ=Europe/London — at Initial Version

Reported by: Alex Willmerer <al.willmer@…> Owned by:
Priority: normal Milestone: 0.12.6
Component: general Version: 1.1.1dev
Severity: normal Keywords: timezone
Cc: Branch:
Release Notes:
API Changes:
Internal Changes:

Description

Three unit tests in source:/trunk/trac/util/tests/datefmt.py fail in latest trunk (r12624 on Ubuntu 13.10/Python 2.7.5, set to the UK timezone. trac.util.to_datetime(<n>) returns a datetime that is 1 hour ahead of that returned by datetime.fromtimestamp(<n>), where n is a POSIX timestamp.

In January 1970 the UK was 1 hour ahead of UTC. This was changed in October 1971, since then the UK has been on GMT (UTC+0) during winter months.

(venv)$ PYTHONPATH=. python trac/util/tests/datefmt.py
................F.FF...................................................................................
======================================================================
FAIL: test_to_datetime (__main__.DateFormatTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "trac/util/tests/datefmt.py", line 716, in test_to_datetime
    self.assertEqual(datefmt.to_datetime(23), expected)
AssertionError: datetime.datetime(1970, 1, 1, 2, 0, 23, tzinfo=<LocalTimezone "GMT" 0:00:00>) != datetime.datetime(1970, 1, 1, 1, 0, 23, tzinfo=<LocalTimezone "GMT" 0:00:00>)

======================================================================
FAIL: test_to_datetime_microsecond_negative_timestamps (__main__.DateFormatTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "trac/util/tests/datefmt.py", line 734, in test_to_datetime_microsecond_negative_timestamps
    self.assertEqual(datefmt.to_datetime(-2345678912), expected)
AssertionError: datetime.datetime(1970, 1, 1, 1, 20, 54, 321088, tzinfo=<LocalTimezone "GMT" 0:00:00>) != datetime.datetime(1970, 1, 1, 0, 20, 54, 321088, tzinfo=<LocalTimezone "GMT" 0:00:00>)

======================================================================
FAIL: test_to_datetime_microsecond_timestamps (__main__.DateFormatTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "trac/util/tests/datefmt.py", line 723, in test_to_datetime_microsecond_timestamps
    self.assertEqual(datefmt.to_datetime(2345678912), expected)
AssertionError: datetime.datetime(1970, 1, 1, 2, 39, 5, 678912, tzinfo=<LocalTimezone "GMT" 0:00:00>) != datetime.datetime(1970, 1, 1, 1, 39, 5, 678912, tzinfo=<LocalTimezone "GMT" 0:00:00>)

----------------------------------------------------------------------
Ran 103 tests in 0.355s

FAILED (failures=3)

Other timezones are not affected (checked by Jun Omae)

$ git status -sb
## 0.12-stable
$ TZ=Europe/London ~/venv/py24/bin/python setup.py test -s trac.util.tests.datefmt.suite ...
FAILED (failures=3)
$ TZ=GMT ~/venv/py24/bin/python setup.py test -s trac.util.tests.datefmt.suite ...
OK
$ TZ=Europe/Berlin ~/venv/py24/bin/python setup.py test -s trac.util.tests.datefmt.suite ...
OK

Change History (0)

Note: See TracTickets for help on using tickets.