﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
27699	parse_duration returns None if passed a string with a negative number of seconds	Filipe L B Correia	hardik1997	"For instance, `parse_duration('172800')` correctly returns `timedelta(2)` (2 days), while `parse_duration('-172800')` incorrectly returns `None` instead of `timedelta(-2)` (-2 days).

This particularly affects the DurationField in SQLite3, since it `parse_duration` is used to read the value from the database, and a negative duration is stored as a negative number.

I would suggest adding an optional minus sign in to the seconds pattern (maybe also for the hours and minutes?), as there is for the days pattern:
{{{
standard_duration_re = re.compile(
    r'^'
    r'(?:(?P<days>-?\d+) (days?, )?)?'
    r'((?:(?P<hours>\d+):)(?=\d+:\d+))?'
    r'(?:(?P<minutes>\d+):)?'
    r'(?P<seconds>-?\d+)'
    r'(?:\.(?P<microseconds>\d{1,6})\d{0,6})?'
    r'$'
)
}}}
Or have an alternative pattern:
{{{
negative_seconds_duration_re = re.compile(
    r'^'
    r'(?P<seconds>-\d+)'
    r'$'
)
}}}

If the current behavior is indeed the intended behavior for the `parse_duration` function, then one should fix the `db.backends.base.operations.convert_durationfield_value` function to handle a negative value for the DurationField."	Bug	closed	Utilities	1.10	Normal	fixed	parse_duration, DurationField	hardik1997	Accepted	1	0	0	0	0	0
