Skip to content

Instantly share code, notes, and snippets.

@meskarune
Created March 16, 2018 04:44
Show Gist options
  • Save meskarune/837214581e80045d0c9c2eb0d904df5c to your computer and use it in GitHub Desktop.
Save meskarune/837214581e80045d0c9c2eb0d904df5c to your computer and use it in GitHub Desktop.
a function to print calendars
local function cal(starts_on, days_in_month)
local n = starts_on - 1 -- column number
local s = { string.rep(" ",n) }
for day = 1,days_in_month do
s[#s+1] = string.format(" %2d", day)
n = n + 1
if n >= 7 then
s[#s+1] = "\n"
n = 0
end
end
if n > 0 then s[#s+1] = "\n" end
return table.concat(s,"")
end
print(cal(5,30))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment