Edgewall Software

Opened 8 years ago

Closed 8 years ago

Last modified 7 years ago

#11012 closed defect (fixed)

regression in format_date, etc.

Reported by: Christian Boos Owned by: Jun Omae
Priority: normal Milestone: 1.0.1
Component: general Version: 1.0-stable
Severity: major Keywords: datetime
Cc: Branch:
Release Notes:

Fixed regression in support of format='iso8601' for format_date and format_time.

API Changes:
Internal Changes:

Description (last modified by Christian Boos)

Looks like in r11445 the support for format='iso8601' in format_date and format_time is gone. We probably didn't have unit tests for that feature, but it was documented (format_datetime).

I suppose something like this would do:

  • datefmt.py

    197197def _format_datetime(t, format, tzinfo, locale, hint):
    198198    t = to_datetime(t, tzinfo or localtz)
     200    if format == 'iso8601':
     201        return _format_datetime_without_babel(t, format + hint)
    200203    if locale == 'iso8601':
    201204        format = _ISO8601_FORMATS[hint].get(format, format)

(+ some tests, of course)

Attachments (0)

Change History (5)

comment:1 by Jun Omae, 8 years ago

Owner: set to Jun Omae
Status: newassigned

Oh…. The unit tests for format_datetime with format=iso8601 are in branches/1.0-stable/trac/util/tests/datefmt.py#L526, but the tests for format_date and format_time are missing.

I'll commit the patch with tests later. Thanks!

$ PYTHONPATH=$PWD ~/venv/py25/bin/python
Python 2.5.6 (r256:88840, Feb 29 2012, 04:03:24)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-51)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from trac.util.datefmt import to_datetime, format_datetime, format_date, format_time
>>> dt = to_datetime(None)
>>> format_datetime(dt, format='iso8601')      # ok
>>> format_datetime(dt, format='iso8601date')  # ok
>>> format_datetime(dt, format='iso8601time')  # ok
>>> format_date(dt, format='iso8601')          # expected '2013-01-10'
>>> format_time(dt, format='iso8601')          # expected '01:12:23+09:00'

comment:2 by Christian Boos, 8 years ago

Great! Thank you Jun.

comment:3 by Christian Boos, 8 years ago

Description: modified (diff)

comment:4 by Jun Omae, 8 years ago

Resolution: fixed
Status: assignedclosed

The patch with unit tests is committed in [11510-11511]. Thanks.

comment:5 by Ryan J Ollos <ryan.j.ollos@…>, 7 years ago

Release Notes: modified (diff)

Modify Ticket

Change Properties
Set your email in Preferences
as closed The owner will remain Jun Omae.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from Jun Omae to the specified user.

Add Comment

E-mail address and name can be saved in the Preferences .
Note: See TracTickets for help on using tickets.