+tests
This commit is contained in:
parent
eaa1e15d0b
commit
a0e11de0df
1 changed files with 21 additions and 13 deletions
|
@ -141,19 +141,27 @@ def plural(amount, unit, plural='s'):
|
||||||
|
|
||||||
def formatDuration(ms, verbosity=0, years=True, hours=True, milliseconds=True):
|
def formatDuration(ms, verbosity=0, years=True, hours=True, milliseconds=True):
|
||||||
'''
|
'''
|
||||||
verbosity
|
verbosity
|
||||||
0: D:HH:MM:SS
|
0: D:HH:MM:SS
|
||||||
1: Dd Hh Mm Ss
|
1: Dd Hh Mm Ss
|
||||||
2: D days H hours M minutes S seconds
|
2: D days H hours M minutes S seconds
|
||||||
years
|
years
|
||||||
True: 366 days are 1 year 1 day
|
True: 366 days are 1 year 1 day
|
||||||
False: 366 days are 366 days
|
False: 366 days are 366 days
|
||||||
hours
|
hours
|
||||||
True: 30 seconds are 00:00:30
|
True: 30 seconds are 00:00:30
|
||||||
False: 30 seconds are 00:30
|
False: 30 seconds are 00:30
|
||||||
milliseconds
|
milliseconds
|
||||||
True: always display milliseconds
|
True: always display milliseconds
|
||||||
False: never 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:
|
if years:
|
||||||
y = int(ms / 31536000000)
|
y = int(ms / 31536000000)
|
||||||
|
|
Loading…
Reference in a new issue