Difference between revisions of "Module:Calendar date/recurring"
Jump to navigation
Jump to search
blackwiki>Howcheng |
blackwiki>Howcheng |
||
| Line 22: | Line 22: | ||
local date = os.time{year=year, month=month, day=1} | local date = os.time{year=year, month=month, day=1} | ||
local dateparts = os.date("*t", date) | local dateparts = os.date("*t", date) | ||
| − | + | return dateparts["wday"] | |
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
end | end | ||
return p | return p | ||
Revision as of 00:05, 27 March 2019
Documentation for this module may be created at Module:Calendar date/recurring/doc
--[[
Calculates the Gregorian date of a recurring holiday that varies year-to-year, but follows the rule "Nth [day of week] of [month]"
"month" = month number (1 to 12)
"weeknumber" = number of week (1 to 4, or -1 to mean "last")
"dayofweek" = number that represents the day of the week, where 1 = Sunday and 7 = Saturday
"year" = Gregorian calendar year
]]
require('Module:No globals')
local p = {}
function p.calculate(frame)
local args = frame.args
local ONE_DAY = 86400 -- number of seconds in one day
local year = tonumber(args.year)
local month = tonumber(args.month)
local date = os.time{year=year, month=month, day=1}
local dateparts = os.date("*t", date)
return dateparts["wday"]
end
return p