This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author vstinner
Recipients amaury.forgeotdarc, belopolsky, jribbens, vstinner, webograph
Date 2008-11-14.21:59:42
SpamBayes Score 5.91498e-08
Marked as misclassified No
Message-id <>
In-reply-to <>
> def formatTimedelta(delta):
>    return "{0}h {1}min {2}sec".format(*str(delta).split(':'))

OMG, this is ugly! Conversion to string and reparse the formatted text :-/ 
Your code doesn't work with different units than hours, minutes or seconds:

['4 days, 1', '32', '01']
>>> str(timedelta(hours=1, minutes=32, seconds=1, microseconds=2)).split(":")
['1', '32', '01.000002']

> or you can convert delta to time using an arbitrary anchor date
> and extract hms that way:

How? I don't understand your suggestion.

> (depending on your needs you may want to add delta.days*24 to the hours)

The goal of the new operators (timedelta / timedelta, divmod(timedelta, 
timedelta), etc.) is to avoid the use of the timedelta "internals" (days, 
seconds and microseconds attributes) and give a new "natural" way to process 
time deltas.
Date User Action Args
2008-11-14 21:59:44vstinnersetrecipients: + vstinner, jribbens, amaury.forgeotdarc, belopolsky, webograph
2008-11-14 21:59:43vstinnerlinkissue2706 messages
2008-11-14 21:59:42vstinnercreate