#25060: Add support for str(timedelta) representation in parse_duration
-----------------------------+--------------------------------------
     Reporter:  vmspike      |                    Owner:  nobody
         Type:  New feature  |                   Status:  new
    Component:  Utilities    |                  Version:  1.8
     Severity:  Normal       |               Resolution:
     Keywords:               |             Triage Stage:  Unreviewed
    Has patch:  1            |      Needs documentation:  0
  Needs tests:  0            |  Patch needs improvement:  0
Easy pickings:  1            |                    UI/UX:  0
-----------------------------+--------------------------------------

Comment (by vmspike):

 For now - no. DurationField is not in the list of officially supported
 field types, docs say that some other fields can work as well but some of
 them need additional work. Seems for other types `str()` method is called
 by default. So DurationField support is just new feature for django-
 hstore. I'm working on support of additional fields but not as the part of
 django.

 I've put `parse_duration()` patch here because I thought it can be useful
 for django core itself. English specificity can be avoided using more
 versatile regex like:
 {{{
 str_timedelta_duration_re = re.compile(
     r'^'
     r'(?:(?P<days>-?\d+) \w+, )?'
     r'((?:(?P<hours>\d+):)(?=\d+:\d+))?'
     r'(?:(?P<minutes>\d+):)?'
     r'(?P<seconds>\d+)'
     r'(?:\.(?P<microseconds>\d{1,6})\d{0,6})?'
     r'$'
 )
 }}}

--
Ticket URL: <https://code.djangoproject.com/ticket/25060#comment:5>
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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/065.a72235c5029dcee9da3715a6dfa39ec4%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to