STINNER Victor <[EMAIL PROTECTED]> added the comment:
> 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.
_______________________________________
Python tracker <[EMAIL PROTECTED]>
<http://bugs.python.org/issue2706>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com