#33349: Add option to produce duration_string without days
------------------------------+--------------------------------------
     Reporter:  Claude Paroz  |                    Owner:  nobody
         Type:  New feature   |                   Status:  closed
    Component:  Forms         |                  Version:  dev
     Severity:  Normal        |               Resolution:  wontfix
     Keywords:                |             Triage Stage:  Unreviewed
    Has patch:  0             |      Needs documentation:  0
  Needs tests:  0             |  Patch needs improvement:  0
Easy pickings:  0             |                    UI/UX:  0
------------------------------+--------------------------------------

Comment (by Claude Paroz):

 For my use case, I think the shorter would be:
 {{{
     def prepare_value(self, value):
         if isinstance(value, datetime.timedelta):
             seconds = value.days * 24 * 3600 + value.seconds
             hours = seconds // 3600
             minutes = seconds % 3600 // 60
             value = '{:02d}:{:02d}'.format(hours, minutes)
         return value
 }}}

-- 
Ticket URL: <https://code.djangoproject.com/ticket/33349#comment:3>
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/065.2dc7673b6ca0fce05994f5e812a6f0ea%40djangoproject.com.

Reply via email to