From 2b961ff5c3058b477e1ead61d8fa139f126509fd Mon Sep 17 00:00:00 2001 From: Aki Date: Thu, 8 Feb 2024 22:31:47 +0100 Subject: Generate empty rolling table --- activity.lua | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) (limited to 'activity.lua') diff --git a/activity.lua b/activity.lua index 9a602b5..405dc05 100644 --- a/activity.lua +++ b/activity.lua @@ -3,7 +3,32 @@ local git = require "activity.git" local activity = {} -function activity.generate_table (year, lookup, format) +local +function generate_rolling (lookup, format, date) + date = date or os.date"*t" + local rows = "" + local weekdays = {"", "Mon", "", "Wed", "", "Fri", ""} + + for index, weekday in pairs(weekdays) do + rows = rows .. format.label(weekday) + for week=0,51 do + rows = rows .. format.cell(0) + end + if date.wday >= index then + rows = rows .. format.cell(0) + else + rows = rows .. format.spot() + end + rows = rows .. "\n" + end + return format.start_document"Activity" .. format.start_table() .. rows .. format.end_table() .. format.end_document() +end + + +function activity.generate_table (year, lookup, format, ...) + if year == "rolling" then + return generate_rolling(lookup, format, ...) + end year = year or dates.this_year() local function day_of_year (first_weekday, week, weekday) -- cgit v1.1