summaryrefslogtreecommitdiff
path: root/django/utils/dateparse.py
diff options
context:
space:
mode:
authorДилян Палаузов <dilyanpalauzov@users.noreply.github.com>2017-11-06 10:23:29 -0500
committerTim Graham <timograham@gmail.com>2017-11-07 09:08:46 -0500
commitc69e4bc69166b2d752b437a651dfa91f8b53ecfd (patch)
tree49cb2c1b54962eff1a02636062b213397003e7ed /django/utils/dateparse.py
parent00b93c2b1ecdda978f067309c6feafda633a7264 (diff)
downloaddjango-c69e4bc69166b2d752b437a651dfa91f8b53ecfd.tar.gz
Fixed #28769 -- Replaced 'x if x else y' with 'x or y'.
Diffstat (limited to 'django/utils/dateparse.py')
-rw-r--r--django/utils/dateparse.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/django/utils/dateparse.py b/django/utils/dateparse.py
index ffb37afcdf..e0e5e244c7 100644
--- a/django/utils/dateparse.py
+++ b/django/utils/dateparse.py
@@ -131,9 +131,11 @@ def parse_duration(value):
Also supports ISO 8601 representation and PostgreSQL's day-time interval
format.
"""
- match = standard_duration_re.match(value)
- if not match:
- match = iso8601_duration_re.match(value) or postgres_interval_re.match(value)
+ match = (
+ standard_duration_re.match(value) or
+ iso8601_duration_re.match(value) or
+ postgres_interval_re.match(value)
+ )
if match:
kw = match.groupdict()
days = datetime.timedelta(float(kw.pop('days', 0) or 0))