optionaly display short runtime, add languages2Letter

This commit is contained in:
j 2008-06-19 16:41:53 +02:00
parent 832176181c
commit 406fc19606
2 changed files with 13 additions and 3 deletions

View file

@ -139,7 +139,7 @@ def plural(amount, unit, plural='s'):
else: unit = plural
return "%s %s" % (formatThousands(amount), unit)
def ms2runtime(ms):
def ms2runtime(ms, shortenLong=False):
'''
>>> ms2runtime(5000)
'5 seconds'
@ -167,6 +167,9 @@ def ms2runtime(ms):
if days >= 365:
years = int(days / 365)
days = days % 365
if shortenLong and years > 0 or days > 99:
runtimeString = ("%sy" % years, "%sd" % days, "%sh" % hours, "%sm" % minutes, "%ss" % seconds)
else:
runtimeString = (plural(years, 'year'), plural(days, 'day'),
plural(hours,'hour'), plural(minutes, 'minute'), plural(seconds, 'second'))
runtimeString = filter(lambda x: not x.startswith('0'), runtimeString)

View file

@ -234,3 +234,10 @@ def englishName(lang):
return l[0]
return None
def languages2Letter():
languages = []
for l in _iso639_languages:
if l[2]:
languages.append(l[2])
return languages