[Django] #32727: Support spaces separaters in ISO-8601 datetimes between times and timezone strings

2 views
Skip to first unread message

Django

unread,
May 7, 2021, 9:16:07 PM5/7/21
to django-...@googlegroups.com
#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 | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
--------------------------------------+------------------------
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>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
May 7, 2021, 9:16:59 PM5/7/21
to django-...@googlegroups.com
#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.

--

--
Ticket URL: <https://code.djangoproject.com/ticket/32727#comment:1>

Django

unread,
May 7, 2021, 9:26:08 PM5/7/21
to django-...@googlegroups.com
#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) 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.

--

--
Ticket URL: <https://code.djangoproject.com/ticket/32727#comment:2>

Django

unread,
May 7, 2021, 9:27:41 PM5/7/21
to django-...@googlegroups.com
#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) 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) to parse ISO-8601 datetime strings, and
python-dateutil does not.

https://github.com/dateutil/dateutil/blob/master/dateutil/parser/isoparser.py

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.

--

--
Ticket URL: <https://code.djangoproject.com/ticket/32727#comment:3>

Django

unread,
May 7, 2021, 9:31:25 PM5/7/21
to django-...@googlegroups.com
#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) to parse ISO-8601 datetime strings, and
> python-dateutil does not.
>
> https://github.com/dateutil/dateutil/blob/master/dateutil/parser/isoparser.py


>
> 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) to parse ISO-8601 datetime strings, and
python-dateutil does not.

https://github.com/dateutil/dateutil/blob/master/dateutil/parser/isoparser.py

I would recommend that Django:

1) Depend on python-dateutil for datetime string parsing


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.

--

--
Ticket URL: <https://code.djangoproject.com/ticket/32727#comment:4>

Django

unread,
May 7, 2021, 9:34:21 PM5/7/21
to django-...@googlegroups.com
#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) to parse ISO-8601 datetime strings, and
> python-dateutil does not.
>
> https://github.com/dateutil/dateutil/blob/master/dateutil/parser/isoparser.py


>
> I would recommend that Django:
>

> 1) Depend on python-dateutil for datetime string parsing


> 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 (brittle) regex to parse ISO-8601 datetime strings, and
python-dateutil does not.

https://github.com/dateutil/dateutil/blob/master/dateutil/parser/isoparser.py

I would recommend that Django:

1) Depend on python-dateutil for datetime string parsing


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.

--

--
Ticket URL: <https://code.djangoproject.com/ticket/32727#comment:5>

Django

unread,
May 7, 2021, 9:35:04 PM5/7/21
to django-...@googlegroups.com
#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 (brittle) regex to parse ISO-8601 datetime strings, and
> python-dateutil does not.
>
> https://github.com/dateutil/dateutil/blob/master/dateutil/parser/isoparser.py


>
> I would recommend that Django:
>

> 1) Depend on python-dateutil for datetime string parsing


> 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.utils.dateparse.parse_datetime` parses this correctly.

This is also a valid ISO-8601 datetime string:


2012-04-23T10:20:30.400 -02

`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 (brittle) regex to parse ISO-8601 datetime strings, and
python-dateutil does not.

https://github.com/dateutil/dateutil/blob/master/dateutil/parser/isoparser.py

I would recommend that Django:

1) Depend on python-dateutil for datetime string parsing


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.

--

--
Ticket URL: <https://code.djangoproject.com/ticket/32727#comment:6>

Django

unread,
May 7, 2021, 9:35:53 PM5/7/21
to django-...@googlegroups.com
#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.utils.dateparse.parse_datetime` parses this correctly.


>
> This is also a valid ISO-8601 datetime string:
>

> 2012-04-23T10:20:30.400 -02
>


> `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 (brittle) regex to parse ISO-8601 datetime strings, and
> python-dateutil does not.
>
> https://github.com/dateutil/dateutil/blob/master/dateutil/parser/isoparser.py


>
> I would recommend that Django:
>

> 1) Depend on python-dateutil for datetime string parsing


> 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.utils.dateparse.parse_datetime` parses this correctly.

This is also a valid ISO-8601 datetime string:


2012-04-23T10:20:30.400 -02

`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 (brittle) regex to parse ISO-8601 datetime strings, and
python-dateutil does not.

https://github.com/dateutil/dateutil/blob/master/dateutil/parser/isoparser.py

I would recommend that Django:

1) Depend on python-dateutil for datetime string parsing


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.

--

--
Ticket URL: <https://code.djangoproject.com/ticket/32727#comment:7>

Django

unread,
May 7, 2021, 9:37:56 PM5/7/21
to django-...@googlegroups.com
#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.utils.dateparse.parse_datetime` parses this correctly.


>
> This is also a valid ISO-8601 datetime string:
>

> 2012-04-23T10:20:30.400 -02
>


> `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 (brittle) regex to parse ISO-8601 datetime strings, and
> python-dateutil does not.
>
> https://github.com/dateutil/dateutil/blob/master/dateutil/parser/isoparser.py


>
> I would recommend that Django:
>

> 1) Depend on python-dateutil for datetime string parsing


> 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.utils.dateparse.parse_datetime` parses this correctly.

This is also a valid ISO-8601 datetime string:


2012-04-23T10:20:30.400 -02

`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 (brittle) regex to parse ISO-8601 datetime strings, and
python-dateutil does not.

https://github.com/django/django/blob/main/django/utils/dateparse.py#L22
https://github.com/dateutil/dateutil/blob/master/dateutil/parser/isoparser.py

I would recommend that Django:

1) Depend on python-dateutil for datetime string parsing


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.

--

--
Ticket URL: <https://code.djangoproject.com/ticket/32727#comment:8>

Django

unread,
May 7, 2021, 9:40:21 PM5/7/21
to django-...@googlegroups.com
#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.utils.dateparse.parse_datetime` parses this correctly.


>
> This is also a valid ISO-8601 datetime string:
>

> 2012-04-23T10:20:30.400 -02
>


> `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 (brittle) regex to parse ISO-8601 datetime strings, and
> python-dateutil does not.
>
> https://github.com/django/django/blob/main/django/utils/dateparse.py#L22
> https://github.com/dateutil/dateutil/blob/master/dateutil/parser/isoparser.py


>
> I would recommend that Django:
>

> 1) Depend on python-dateutil for datetime string parsing


> 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.utils.dateparse.parse_datetime` parses this correctly.

This is also a valid ISO-8601 datetime string:


2012-04-23T10:20:30.400 -02

`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 (brittle) regex to parse ISO-8601 datetime strings, and
python-dateutil does not.

https://github.com/django/django/blob/main/django/utils/dateparse.py#L22
https://github.com/dateutil/dateutil/blob/master/dateutil/parser/isoparser.py

I would recommend that Django:

1) Depend on python-dateutil for datetime string parsing


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.

--

--
Ticket URL: <https://code.djangoproject.com/ticket/32727#comment:9>

Django

unread,
May 7, 2021, 10:49:40 PM5/7/21
to django-...@googlegroups.com
#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:

> GitHub Pull Request: https://github.com/django/django/pull/14368
>


> 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.utils.dateparse.parse_datetime` parses this correctly.


>
> This is also a valid ISO-8601 datetime string:
>

> 2012-04-23T10:20:30.400 -02
>


> `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 (brittle) regex to parse ISO-8601 datetime strings, and
> python-dateutil does not.
>
> https://github.com/django/django/blob/main/django/utils/dateparse.py#L22
> https://github.com/dateutil/dateutil/blob/master/dateutil/parser/isoparser.py


>
> I would recommend that Django:
>

> 1) Depend on python-dateutil for datetime string parsing


> 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.

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.utils.dateparse.parse_datetime` parses this correctly.

This is also a valid ISO-8601 datetime string:


2012-04-23T10:20:30.400 -02

`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 (brittle) regex to parse ISO-8601 datetime strings, and
python-dateutil does not.

https://github.com/django/django/blob/main/django/utils/dateparse.py#L22
https://github.com/dateutil/dateutil/blob/master/dateutil/parser/isoparser.py

I recommend that Django:

1) Depend on python-dateutil for datetime string parsing

OR

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.

--

--
Ticket URL: <https://code.djangoproject.com/ticket/32727#comment:10>

Django

unread,
May 8, 2021, 2:58:26 AM5/8/21
to django-...@googlegroups.com
#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: dev
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
----------------------------+------------------------------------
Changes (by Claude Paroz):

* version: 3.2 => dev
* stage: Unreviewed => Accepted


Comment:

Thanks for the patch. Ticket accepted at least to fix the space issue.

Could you please open a new thread with your rationales on the django-
developers mailing list about the suggestion of depending on python-
dateutil? Adding a new project dependency is no light decision, so it
would need to be supported by a clear majority of developers.

--
Ticket URL: <https://code.djangoproject.com/ticket/32727#comment:11>

Django

unread,
May 8, 2021, 2:58:51 AM5/8/21
to django-...@googlegroups.com
#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: dev
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
----------------------------+------------------------------------
Changes (by Claude Paroz):

* has_patch: 0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/32727#comment:12>

Django

unread,
May 11, 2021, 7:00:52 PM5/11/21
to django-...@googlegroups.com
#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: dev
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
----------------------------+------------------------------------

Comment (by Ben Wilber):

Replying to [comment:12 Claude Paroz]:

Yes I'll start a thread on django devs. Thanks!

--
Ticket URL: <https://code.djangoproject.com/ticket/32727#comment:13>

Django

unread,
Jun 24, 2021, 4:11:22 AM6/24/21
to django-...@googlegroups.com
#32727: Support spaces separaters in ISO-8601 datetimes between times and timezone
strings
----------------------------+---------------------------------------------
Reporter: Ben Wilber | Owner: Ben Wilber
Type: Bug | Status: assigned

Component: Utilities | Version: dev
Severity: Normal | Resolution:
Keywords: | Triage Stage: Ready for checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
----------------------------+---------------------------------------------
Changes (by Mariusz Felisiak):

* owner: nobody => Ben Wilber
* status: new => assigned
* stage: Accepted => Ready for checkin


--
Ticket URL: <https://code.djangoproject.com/ticket/32727#comment:14>

Django

unread,
Jun 24, 2021, 4:49:53 AM6/24/21
to django-...@googlegroups.com
#32727: Support spaces separaters in ISO-8601 datetimes between times and timezone
strings
----------------------------+---------------------------------------------
Reporter: Ben Wilber | Owner: Ben Wilber
Type: Bug | Status: closed
Component: Utilities | Version: dev
Severity: Normal | Resolution: fixed

Keywords: | Triage Stage: Ready for checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
----------------------------+---------------------------------------------
Changes (by Mariusz Felisiak <felisiak.mariusz@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"fff4870bfa7ed4d9ab6be0060364b23c66ad1af0" fff4870]:
{{{
#!CommitTicketReference repository=""
revision="fff4870bfa7ed4d9ab6be0060364b23c66ad1af0"
Fixed #32727 -- Allowed spaces before time zone offset in
parse_datetime().
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/32727#comment:15>

Reply all
Reply to author
Forward
0 new messages