Fixed #36747 -- Added support for parsing weeks in django.utils.dateparse.parse_duration().#20295
Conversation
456d0d4 to
6c6d2e3
Compare
jacobtylerwalls
left a comment
There was a problem hiding this comment.
Thanks @varunkasyap 👍 .
I just reclassified this to a new feature on Trac, could you add some docs?
|
Hi @jacobtylerwalls, thanks for the review. For the documentation, are we targeting Django 6.1? this is how my changes look like: |
6c6d2e3 to
951013c
Compare
951013c to
b1b5b37
Compare
jacobtylerwalls
left a comment
There was a problem hiding this comment.
Thanks for the updates ⭐
I pushed tiny edits to docs.
docs/ref/utils.txt
Outdated
| ISO 8601 duration parsing now supports weeks (``PnW``). Years (``Y``) and | ||
| months (``M``) remain unsupported. |
There was a problem hiding this comment.
I'll move some of this into the text above. The rule of thumb is that the versionchanged directive shouldn't contain any information we want to keep forever, as when 6.1 goes EOL, we drop this whole directive.
There was a problem hiding this comment.
Also, make sure to indent.
docs/releases/6.1.txt
Outdated
| * :func:`django.utils.dateparse.parse_duration` now supports ISO 8601 durations | ||
| expressed in weeks (``PnW``). Years (``Y``) and months (``M``) remain | ||
| unsupported as they cannot be represented by ``datetime.timedelta`` | ||
| (:ticket:`36747`). |
There was a problem hiding this comment.
Ticket numbers only necessary for regressions in patch release notes.
docs/releases/6.1.txt
Outdated
| ~~~~~~~~~ | ||
|
|
||
| * ... | ||
| * :func:`django.utils.dateparse.parse_duration` now supports ISO 8601 durations |
There was a problem hiding this comment.
Using ~django helps reduce the verbosity of the link text.
📊 Coverage Report for Changed FilesNote: Missing lines are warnings only. Some lines may not be covered by SQLite tests as they are database-specific. For more information about code coverage on pull requests, see the contributing documentation. |


Trac ticket number
ticket-36747
Branch description
Added support for parsing weeks in ISO 8601 duration strings (e.g., 'P4W') within django.utils.dateparse.parse_duration(). Previously, this would return None.
This PR also updates the docstrings and documentation to explicitly clarify that while ISO 8601 duration parsing is supported, years (Y) and months (M) remain unsupported
Checklist
mainbranch.