diff options
author | Aki <please@ignore.pl> | 2024-02-08 22:31:47 +0100 |
---|---|---|
committer | Aki <please@ignore.pl> | 2024-02-08 22:35:46 +0100 |
commit | 2b961ff5c3058b477e1ead61d8fa139f126509fd (patch) | |
tree | 1191780309675195806c9d63446ab10f8314220a /activity.lua | |
parent | 89b7fc43530535ea0fb2114e5fa0cf5660ca37a0 (diff) | |
download | activity-2b961ff5c3058b477e1ead61d8fa139f126509fd.zip activity-2b961ff5c3058b477e1ead61d8fa139f126509fd.tar.gz activity-2b961ff5c3058b477e1ead61d8fa139f126509fd.tar.bz2 |
Generate empty rolling table
Diffstat (limited to 'activity.lua')
-rw-r--r-- | activity.lua | 27 |
1 files changed, 26 insertions, 1 deletions
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) |