fix time translation patch

This commit is contained in:
Damien Elmes 2017-12-04 12:33:23 +10:00
parent fcccf12ba6
commit c67fc3e769
2 changed files with 9 additions and 2 deletions

View file

@ -69,8 +69,8 @@ def fmtTimeSpan(time, pad=0, point=0, short=False, inTime=False, unit=99):
fmt = inTimeTable[type](_pluralCount(time, point))
else:
fmt = timeTable[type](_pluralCount(time, point))
timestr = "%(a)d.%(b)df" % {'a': pad, 'b': point}
return locale.format_string("%" + (fmt % timestr), time)
timestr = "%%%(a)d.%(b)df" % {'a': pad, 'b': point}
return locale.format_string(fmt % timestr, time)
def optimalPeriod(time, point, unit):
if abs(time) < 60 or unit < 1:

7
tests/test_utils.py Normal file
View file

@ -0,0 +1,7 @@
# coding: utf-8
from anki.utils import fmtTimeSpan
def test_fmtTimeSpan():
assert fmtTimeSpan(5) == "5 seconds"
assert fmtTimeSpan(5, inTime=True) == "in 5 seconds"