add period progress script
This commit is contained in:
34
community/period_progress.lua
Normal file
34
community/period_progress.lua
Normal file
@@ -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
|
||||||
Reference in New Issue
Block a user