Content deleted Content added
Holly Cheng (talk | contribs) No edit summary |
Replace Module:No globals with require( "strict" ) |
||
(3 intermediate revisions by 2 users not shown) | |||
Line 10:
]]
require('
local p = {}
Line 20:
local year = tonumber(args.year)
local month = tonumber(args.month)
local date = os.time{year=year, month=month, day=1}▼
local dayofweek = tonumber(args.dayofweek)
▲ local date = os.time{year=year, month=month, day=1}
local dateparts = os.date("*t", date)
if
-- find the first [dayofweek] of this month
while dateparts["wday"] ~= dayofweek do
Line 32 ⟶ 34:
-- add the correct number of weeks
▲ local weeknumber = tonumber(args.weeknumber)
if weeknumber > 1 then
date = date + ((weeknumber - 1) * (7 * ONE_DAY))
Line 44 ⟶ 45:
-- go back one day to get the last day of the month we want
date = date - ONE_DAY
dateparts = os.date("*t", date)
-- go backwards until we find the right day of week
while dateparts["wday"] ~= dayofweek do
date = date - ONE_DAY
dateparts = os.date("*t", date)
end
end
local result = os.date("%Y-%m-%d", date)
|