From 5082289aadc199deb29861d3027c4ef1e1fcbe1e Mon Sep 17 00:00:00 2001 From: weijiuqiao <59040746+weijiuqiao@users.noreply.github.com> Date: Sun, 13 Nov 2022 04:20:54 +0800 Subject: [PATCH] Vocabulary builder: allow longer intervals (#9764) --- plugins/vocabbuilder.koplugin/db.lua | 2 +- plugins/vocabbuilder.koplugin/main.lua | 12 ++++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/plugins/vocabbuilder.koplugin/db.lua b/plugins/vocabbuilder.koplugin/db.lua index 354db8f72..236505306 100644 --- a/plugins/vocabbuilder.koplugin/db.lua +++ b/plugins/vocabbuilder.koplugin/db.lua @@ -227,7 +227,7 @@ function VocabularyBuilder:gotOrForgot(item, isGot) elseif target_count == 7 then due_time = current_time + 24 * 15 * 3600 else - due_time = current_time + 24 * 30 * 3600 + due_time = current_time + 24 * 3600 * 30 * 2 ^ (math.min(target_count - 8, 6)) end item.last_streak_count = item.streak_count diff --git a/plugins/vocabbuilder.koplugin/main.lua b/plugins/vocabbuilder.koplugin/main.lua index 5c5b4a2f6..716a0a5b2 100644 --- a/plugins/vocabbuilder.koplugin/main.lua +++ b/plugins/vocabbuilder.koplugin/main.lua @@ -932,13 +932,17 @@ function VocabItemWidget:getTimeSinceDue() local rounding = elapsed > 0 and math.floor or math.ceil if abs < 60 then - readable_time = abs .. C_("Time", "s") + readable_time = T(C_("Time", "%1s"), abs) elseif abs < 3600 then - readable_time = string.format("%d"..C_("Time", "m"), rounding(abs/60)) + readable_time = T(C_("Time", "%1m"), rounding(abs/60)) elseif abs < 3600 * 24 then - readable_time = string.format("%d"..C_("Time", "h"), rounding(abs/3600)) + readable_time = T(C_("Time", "%1h"), rounding(abs/3600)) + elseif abs < 3600 * 24 * 30 then + readable_time = T(C_("Time", "%1d"), rounding(abs/3600/24)) + elseif abs < 3600 * 24 * 365 then + readable_time = T(C_("Time", "%1 mo."), rounding(abs/3600/24/3)/10) else - readable_time = string.format("%d"..C_("Time", "d"), rounding(abs/3600/24)) + readable_time = T(C_("Time", "%1 yr."), rounding(abs/3600/24/36.5)/10) end if elapsed < 0 then