[Django] #35097: Undocumented behaviour change of utils.dateparse.parse_datetime

12 views
Skip to first unread message

Django

unread,
Jan 8, 2024, 5:18:09 PM1/8/24
to django-...@googlegroups.com
#35097: Undocumented behaviour change of utils.dateparse.parse_datetime
-----------------------------------------+------------------------
Reporter: David Wobrock | Owner: nobody
Type: Uncategorized | Status: new
Component: Utilities | Version: 4.0
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 |
-----------------------------------------+------------------------
Hey,

A bit late to the party, but in 4.0, we introduced a patch that changed
the behaviour of `django.utils.dateparse.parse_datetime`.
In very short, on Django 3.2
{{{
>>> from django.utils.dateparse import parse_datetime
>>> parse_datetime('2023-01-01')
# Returns None
}}}

And on Django 4.0,
{{{
>>> from django.utils.dateparse import parse_datetime
>>> parse_datetime('2023-01-01')
datetime.datetime(2023, 1, 1, 0, 0)
}}}

The change was introduced in
[https://github.com/django/django/commit/f35ab74752adb37138112657c1bc8b91f50e799b
f35ab74752adb37138112657c1bc8b91f50e799b], which relates to #32892.
The initial ticket considers mainly `parse_time` and `parse_date`, but not
the impacts on `parse_datetime`.

I think this behaviour is valid, since a date without time can be
considered a valid datetime object, with 0 as time values.
But since this change was not documented, I wanted to report it somewhere,
because I couldn't find any other reference to it :)

Though I'm not sure this is the best way to share this information, so
feel free to close the ticket.

--
Ticket URL: <https://code.djangoproject.com/ticket/35097>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Jan 8, 2024, 11:28:46 PM1/8/24
to django-...@googlegroups.com
#35097: Undocumented behaviour change of utils.dateparse.parse_datetime
-------------------------------+--------------------------------------

Reporter: David Wobrock | Owner: nobody
Type: Uncategorized | Status: closed
Component: Utilities | Version: 4.0
Severity: Normal | Resolution: invalid

Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------------------------
Changes (by Mariusz Felisiak):

* status: new => closed
* resolution: => invalid


Comment:

Thanks for the report, however, I'd treat pre-Django 4.0 behavior as a bug
here and we don't document bugfixes.

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

Django

unread,
Jan 9, 2024, 7:41:48 AM1/9/24
to django-...@googlegroups.com
#35097: Undocumented behaviour change of utils.dateparse.parse_datetime
-------------------------------+--------------------------------------
Reporter: David Wobrock | Owner: nobody
Type: Uncategorized | Status: closed
Component: Utilities | Version: 4.0
Severity: Normal | Resolution: invalid
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------------------------

Comment (by David Wobrock):

Makes sense! Thanks for your time Mariusz.

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

Reply all
Reply to author
Forward
0 new messages