diff options
| author | varunkasyap <varunkasyap@hotmail.com> | 2025-11-22 17:54:05 +0530 |
|---|---|---|
| committer | Jacob Walls <jacobtylerwalls@gmail.com> | 2025-12-17 10:19:05 -0500 |
| commit | 0d8548e5831bc610102d5e4b8a2366f26818a28a (patch) | |
| tree | 66afb67472c108cc8301716f2b1bd7037bc63af5 /django/utils | |
| parent | 6cc1231285a20b11058143f8cb0a6b4b3999b23a (diff) | |
Fixed #36747 -- Parsed weeks from ISO 8601 format in parse_duration().
Diffstat (limited to 'django/utils')
| -rw-r--r-- | django/utils/dateparse.py | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/django/utils/dateparse.py b/django/utils/dateparse.py index 42c2684d7c..b95fb21102 100644 --- a/django/utils/dateparse.py +++ b/django/utils/dateparse.py @@ -40,6 +40,7 @@ standard_duration_re = _lazy_re_compile( iso8601_duration_re = _lazy_re_compile( r"^(?P<sign>[-+]?)" r"P" + r"(?:(?P<weeks>\d+([.,]\d+)?)W)?" r"(?:(?P<days>\d+([.,]\d+)?)D)?" r"(?:T" r"(?:(?P<hours>\d+([.,]\d+)?)H)?" @@ -134,8 +135,8 @@ def parse_duration(value): The preferred format for durations in Django is '%d %H:%M:%S.%f'. - Also supports ISO 8601 representation and PostgreSQL's day-time interval - format. + Also supports ISO 8601 representation (excluding years and months) and + PostgreSQL's day-time interval format. """ match = ( standard_duration_re.match(value) |
