#30141: dateparse parse_duration to accept negative durations -----------------------------------------+------------------------ Reporter: heikkimattila | Owner: nobody Type: Uncategorized | Status: new Component: Uncategorized | Version: 1.11 Severity: Normal | Keywords: Triage Stage: Unreviewed | Has patch: 0 Needs documentation: 0 | Needs tests: 0 Patch needs improvement: 0 | Easy pickings: 1 UI/UX: 0 | -----------------------------------------+------------------------ The https://docs.djangoproject.com/en/2.1/_modules/django/utils/dateparse/ defines: {{{ 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'$' ) }}} that doesn't match to negative durations, because of the <hours> definition final (lookahead) part does not have '-?' in it. The following will work: {{{ r'((?:(?P<hours>-?\d+):)(?=-?\d+:-?\d+))?' }}} (Thanks to Konstantin Senichev for finding the fix.)
-- Ticket URL: <https://code.djangoproject.com/ticket/30141> Django <https://code.djangoproject.com/> The Web framework for perfectionists with deadlines. -- You received this message because you are subscribed to the Google Groups "Django updates" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-updates+unsubscr...@googlegroups.com. To post to this group, send email to django-updates@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/056.24209dd3e82ca272caa6ee607285d689%40djangoproject.com. For more options, visit https://groups.google.com/d/optout.