From 6e726d77c223b23ad47cc8b76b35c84cc83d7aa9 Mon Sep 17 00:00:00 2001 From: Evgeny Date: Tue, 24 Aug 2021 09:43:00 +0300 Subject: [PATCH] add period progress script --- community/period_progress.lua | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 community/period_progress.lua diff --git a/community/period_progress.lua b/community/period_progress.lua new file mode 100644 index 0000000..de34b3d --- /dev/null +++ b/community/period_progress.lua @@ -0,0 +1,34 @@ +-- name = "Period progress" +-- description = "Shows period progress" +-- type = "widget" +-- author = "Nikolai Galashev" +-- version = "1.0" +-- arguments_help = "Enter the title and the start and end date in this format: Title 2021 01 31 2021 09 25" + + +function on_resume() + if (next(aio:get_args()) == nil) then + ui:show_text("Tap to enter date") + return + end + + local params = aio:get_args() + start_period = get_time(params[2], params[3], params[4]); + end_period = get_time(params[5], params[6], params[7]); + name_period = params[1] + current_time = os.time() + init_progressbar() +end + +function on_click() + aio:show_args_dialog() +end + +function get_time(y,m,d) + return os.time{day=d,month=m,year=y} +end + +function init_progressbar() + percent = math.floor((current_time - start_period) / ((end_period - start_period) / 100)) + ui:show_progress_bar(name_period..": "..percent.."%", current_time - start_period, end_period - start_period, "#7069f0ae") +end