#32727: Support spaces separaters in ISO-8601 datetimes between times and
timezone
strings
----------------------------+--------------------------------------
Reporter: Ben Wilber | Owner: nobody
Type: Bug | Status: new
Component: Utilities | Version: 3.2
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
----------------------------+--------------------------------------
Description changed by Ben Wilber:
Old description:
> According to ISO-8601, there can be any number of whitespace characters
> between the time strings and timezone strings.
>
> Unfortunately the spec isn't public, but here's the link anyway
> https://www.iso.org/iso-8601-date-and-time-format.html.
>
> Examples:
>
> This is a valid ISO-8601 datetime string:
>
> ```
> 2012-04-23T10:20:30.400-02
> ```
> Django's `django.utils.dateparse.parse_datetime` parses this correctly.
>
> This is also a valid ISO-8601 datetime string:
> ```
> 2012-04-23T10:20:30.400 -02
> ```
> Django's `django.utils.dateparse.parse_datetime` does not parse this
> correctly and returns `None`,
>
> However, `python-dateutil` parses it correctly. The difference is that
> Django uses a very brittle REGEX to parse ISO-8601 datetime strings, and
> python-dateutil does not.
>
> I would recommend that Django:
>
> 1) Depend on python-dateutil
> 2) Inline python-dateutils' parsing functions
>
> As far as I know there is no regex that can parse the full spec of
> ISO-8601 datetime strings.
>
> In the meantime, this is a patch to support (valid) whitespace characters
> between the seconds/millseconds part and the timezone string.
>
> GitHub Pull Request: https://github.com/django/django/pull/14368
New description:
According to ISO-8601, there can be any number of whitespace characters
between the time strings and timezone strings.
Unfortunately the spec isn't public, but here's the link anyway
https://www.iso.org/iso-8601-date-and-time-format.html.
Examples:
This is a valid ISO-8601 datetime string:
2012-04-23T10:20:30.400-02
Django's `django.utils.dateparse.parse_datetime` parses this correctly.
This is also a valid ISO-8601 datetime string:
2012-04-23T10:20:30.400 -02
Django's `django.utils.dateparse.parse_datetime` does not parse this
correctly and returns `None`,
However, `python-dateutil` parses it correctly. The difference is that
Django uses a very brittle REGEX to parse ISO-8601 datetime strings, and
python-dateutil does not.
I would recommend that Django:
1) Depend on python-dateutil
2) Inline python-dateutils' parsing functions
As far as I know there is no regex that can parse the full spec of
ISO-8601 datetime strings.
In the meantime, this is a patch to support (valid) whitespace characters
between the seconds/millseconds part and the timezone string.
GitHub Pull Request: https://github.com/django/django/pull/14368
--
--
Ticket URL: <https://code.djangoproject.com/ticket/32727#comment:1>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/067.87b8e3a12e6865ba851ac1b4d4e46965%40djangoproject.com.