This commit is contained in:
Rolux 2008-07-02 17:07:49 +02:00
parent eaa1e15d0b
commit a0e11de0df

View file

@ -154,6 +154,14 @@ def formatDuration(ms, verbosity=0, years=True, hours=True, milliseconds=True):
milliseconds
True: always display milliseconds
False: never display milliseconds
>>> formatDuration(1000 * 60 * 60 * 24 * 366)
'1:001:00:00:00.000'
>>> formatDuration(1000 * 60 * 60 * 24 * 366, year=False)
'366:00:00:00.000'
>>> formatDuration(1000 * 60 * 60 * 24 * 365 + 2003, verbosity=2)
'1 year 2 seconds 3 milliseconds'
>>> formatDuration(1000 * 30, hours=False, milliseconds=False)
'00:30'
'''
if years:
y = int(ms / 31536000000)