diff options
| author | Farhaan Bukhsh <farhaan.bukhsh@gmail.com> | 2019-11-27 08:14:00 +0100 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2019-11-27 09:43:12 +0100 |
| commit | 42b23d1e79b21ddd8abd7216a6771f105dd7062c (patch) | |
| tree | 0567180d44c1fd9414c15417a618561fa3cea811 /django/utils/dateparse.py | |
| parent | cab36618326524b336517c2c5fd62633916818e0 (diff) | |
Refs #30803 -- Allowed comma separators for decimal fractions in parse_duration().
Diffstat (limited to 'django/utils/dateparse.py')
| -rw-r--r-- | django/utils/dateparse.py | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/django/utils/dateparse.py b/django/utils/dateparse.py index d142e161b6..535655561c 100644 --- a/django/utils/dateparse.py +++ b/django/utils/dateparse.py @@ -137,11 +137,11 @@ def parse_duration(value): ) if match: kw = match.groupdict() - days = datetime.timedelta(float(kw.pop('days', 0) or 0)) sign = -1 if kw.pop('sign', '+') == '-' else 1 if kw.get('microseconds'): kw['microseconds'] = kw['microseconds'].ljust(6, '0') if kw.get('seconds') and kw.get('microseconds') and kw['seconds'].startswith('-'): kw['microseconds'] = '-' + kw['microseconds'] - kw = {k: float(v) for k, v in kw.items() if v is not None} + 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) return days + sign * datetime.timedelta(**kw) |
