Edgewall Software

Opened 8 years ago

Last modified 8 years ago

#12377 closed defect

iso8601 with high time resolution and no timezone leads strange timezone — at Initial Version

Reported by: Jun Omae Owned by:
Priority: low Milestone: 1.0.11
Component: general Version:
Severity: minor Keywords:
Cc: Branch:
Release Notes:
API Changes:
Internal Changes:

Description

I noticed strange behaviors in parse_date() while adding unit tests in [9b9c8a56e/jomae.git].

$ ~/venv/trac/1.0.10/bin/python
Python 2.5.6 (r256:88840, Oct 21 2014, 22:26:35)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from trac.util.datefmt import parse_date, utc
>>> parse_date('2016-01-02T12:34:56.987654', utc)
datetime.datetime(2016, 1, 2, 12, 34, 56, 987654, tzinfo=<FixedOffset "UTC" 0:00:00>)
>>> parse_date('2016-01-02T12:34:56.9876543', utc)
datetime.datetime(2016, 1, 2, 12, 34, 56, 987650, tzinfo=<FixedOffset "None43:None" 19:00:00>)
>>> parse_date('2016-01-02T12:34:56.98765432', utc)
datetime.datetime(2016, 1, 2, 12, 34, 56, 987654, tzinfo=<FixedOffset "None32:None" 8:00:00>)
>>> parse_date('2016-01-02T12:34:56.987654321', utc)
datetime.datetime(2016, 1, 2, 12, 34, 56, 987650, tzinfo=<FixedOffset "None43:21" 19:21:00>)
>>> parse_date('2016-01-02T12:34:56.9876543210', utc)
datetime.datetime(2016, 1, 2, 12, 34, 56, 987654, tzinfo=<FixedOffset "None32:10" 8:10:00>)
>>> parse_date('2016-01-02T12:34:56.98765432109', utc)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "~/venv/trac/1.0.10/lib/python2.5/site-packages/trac/util/datefmt.py", line 615, in parse_date
    raise TracError(msg, _('Invalid Date'))
trac.core.TracError: "2016-01-02T12:34:56.98765432109" is an invalid date, or the date format is not known. Try "MM/dd/YY" or "YYYY-MM-DD" instead.

Change History (0)

Note: See TracTickets for help on using tickets.