Edgewall Software

Opened 15 years ago

Last modified 14 years ago

#8662 closed enhancement

format date in RFC 3339 subset (profile) of ISO 8601 — at Version 1

Reported by: anatoly techtonik <techtonik@…> Owned by:
Priority: normal Milestone: 0.12
Component: rendering Version: 0.11-stable
Severity: normal Keywords: patch
Cc: martin@… Branch:
Release Notes:
API Changes:
Internal Changes:

Description (last modified by Christian Boos)

Currently util.datefmt.format_datetime() is able to produce ISO 8601 compliant format given 'iso8601' as argument. The proposal is to increase interoperability by making datetime format compliant with RFC 3339 profile of ISO 8601.

That means that date will still be ISO 8601, but it will be additionally suitable for generating output that uses RFC 3339 based datetime, such as Atom.

See rfc:3339#section-5.6

  • trac/util/datefmt.py

     
    100100   
    101101    The formatting will be done using the given `format`, which consist
    102102    of conventional `strftime` keys. In addition the format can be 'iso8601'
    103     to specify the international date format.
     103    to specify the international date format (compliant with rfc3339).
    104104
    105105    `tzinfo` will default to the local timezone if left to `None`.
    106106    """
     
    125125    text = t.strftime(format)
    126126    if normalize_Z:
    127127        text = text.replace('+0000', 'Z')
     128        text = text[:-2] + ":" + text[-2:]
    128129    encoding = locale.getpreferredencoding() or sys.getdefaultencoding()
    129130    if sys.platform != 'win32' or sys.version_info[:2] > (2, 3):
    130131        encoding = locale.getlocale(locale.LC_TIME)[1] or encoding

Change History (2)

by anatoly techtonik <techtonik@…>, 15 years ago

Attachment: rfc3339.diff added

comment:1 by Christian Boos, 15 years ago

Description: modified (diff)
Milestone: 0.12

Why not, but please fix the patch (only do this substitution if test[-1] != 'Z').

Note: See TracTickets for help on using tickets.