diff options
| author | starryrbs <1322096624@qq.com> | 2020-12-19 17:53:35 +0800 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2020-12-21 10:28:07 +0100 |
| commit | 2a76f4313423a3b91caade4fce71790630ef9152 (patch) | |
| tree | 591d0303011cb8d5f97d33a96b62663d9d4ea14d /django/utils | |
| parent | 57d05f94c36fd88378e94470e13d1e1dc935748a (diff) | |
Fixed #32269 -- Fixed parse_duration() for negative days in ISO 8601 format.
Diffstat (limited to 'django/utils')
| -rw-r--r-- | django/utils/dateparse.py | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/django/utils/dateparse.py b/django/utils/dateparse.py index 0945c0c761..e069f5df39 100644 --- a/django/utils/dateparse.py +++ b/django/utils/dateparse.py @@ -144,4 +144,6 @@ def parse_duration(value): kw['microseconds'] = '-' + kw['microseconds'] kw = {k: float(v.replace(',', '.')) for k, v in kw.items() if v is not None} days = datetime.timedelta(kw.pop('days', .0) or .0) + if match.re == iso8601_duration_re: + days *= sign return days + sign * datetime.timedelta(**kw) |
