Created
March 16, 2018 04:44
-
-
Save meskarune/837214581e80045d0c9c2eb0d904df5c to your computer and use it in GitHub Desktop.
a function to print calendars
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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