From c416f29b9745b46ab61b1ba25a3beac292a48fd9 Mon Sep 17 00:00:00 2001 From: Evgeny Date: Thu, 9 Jan 2025 15:07:44 +0800 Subject: [PATCH] Fix counter widget future day bug --- community/counter-widget.lua | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/community/counter-widget.lua b/community/counter-widget.lua index eb52909..1183ba0 100644 --- a/community/counter-widget.lua +++ b/community/counter-widget.lua @@ -47,9 +47,14 @@ function on_resume() local passed = date.diff(curr_date, start_date) local passed_days = math.floor(passed:spandays()) + if passed_days < 0 then + table.insert(gui_inst, {"text", "Error: the date can't be in the future"}) + break + end + local idx = get_milestone_idx(passed) local passed_str = passed_days.." days" - if prefs.show_milestones then + if prefs.show_milestones and passed_days > 0 then passed_str = passed_str.." / "..milestones_formatted[idx] end local next_milestone_percent = passed_days / milestones[idx+1] * 100