Opened 5 years ago

Closed 4 years ago

#30803 closed New feature (fixed)

Dateparse function should support comma separators for milliseconds according to ISO-8601

Reported by: Ben Wilber Owned by: Farhaan Bukhsh
Component: Utilities Version: dev
Severity: Normal Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Presently the regex for parsing ISO-8601 formatted datetimes in django.utils.dateparse.parse_time and parse_datetime only supports period (.) separators for milliseconds.

Examples:

2014-08-06T11:00:00.000Z

2014-08-06T11:00:00,000Z

ISO 8601:2004 states that parsers should support both delineators, with a preference for commas. https://www.iso.org/standard/40874.html

A decimal mark, either a comma or a dot (without any preference as stated in resolution 10 of the 22nd General Conference CGPM in 2003,[16] but with a preference for a comma according to ISO 8601:2004)

Github Pull Request: https://github.com/django/django/pull/11818

Change History (9)

comment:1 by Ben Wilber, 5 years ago

Component: UncategorizedUtilities
Type: UncategorizedBug
Version: 2.2master

comment:2 by Simon Charette, 5 years ago

Has patch: set
Triage Stage: UnreviewedAccepted
Type: BugNew feature

I don't see much harm in supporting comma separators but I couldn't get my hand on a copy of ISO 8601:2004 to confirm the report. Tentatively accepting.

Are you aware in any changes in ISO 8601-1:2019 and ISO 8601-2:2019 given they supersede the now withdrawn ISO 8601:2004?

It might be worth adding a mention in the release notes about this change even if it's minor.

in reply to:  2 comment:3 by Ben Wilber, 5 years ago

Replying to Simon Charette:

I don't see much harm in supporting comma separators but I couldn't get my hand on a copy of ISO 8601:2004 to confirm the report. Tentatively accepting.

Are you aware in any changes in ISO 8601-1:2019 and ISO 8601-2:2019 given they supersede the now withdrawn ISO 8601:2004?

It might be worth adding a mention in the release notes about this change even if it's minor.

I'm not aware of anything in the 2019 revisions that has changed regarding periods vs commas for separating milliseconds. Unfortunately the full specs are not publicly available to confirm. I can add a note to the release notes. Which would be the appropriate release notes document to mention this?

comment:4 by Mariusz Felisiak, 5 years ago

Needs documentation: set
Needs tests: set
Owner: changed from nobody to Ben Wilber
Status: newassigned

comment:5 by Farhaan Bukhsh, 4 years ago

Hey, I would love to complete this PR, what can be the next steps? I see writing tests as one of them. Thanks a ton in advance. :)

comment:6 by Mariusz Felisiak, 4 years ago

Needs tests: unset
Owner: changed from Ben Wilber to Farhaan Bukhsh

comment:7 by Mariusz Felisiak, 4 years ago

Needs documentation: unset
Triage Stage: AcceptedReady for checkin

comment:8 by Mariusz Felisiak <felisiak.mariusz@…>, 4 years ago

In 42b23d1e:

Refs #30803 -- Allowed comma separators for decimal fractions in parse_duration().

comment:9 by Mariusz Felisiak <felisiak.mariusz@…>, 4 years ago

Resolution: fixed
Status: assignedclosed

In 1f817daa:

Fixed #30803 -- Allowed comma separators for milliseconds in django.utils.dateparse functions.

Co-Authored-By: Ben Wilber <benwilber@…>

Note: See TracTickets for help on using tickets.
Back to Top