4,212
edits
(Fixed algorithm so that the next "first Tuesday" will be September 5.) |
(Fixing up the get_next_tuesday logic and made it use an offset so that the date calculation uses Pacific Standard Time) |
||
(2 intermediate revisions by the same user not shown) | |||
Line 5:
function p.get_next_tuesday(frame)
local isodate = frame.args.isodate
local
local current_time = os.time() + pst_tzoffset
local current_day_of_week = tonumber(os.date("%w", current_time))
local days_until_tuesday = (9 - current_day_of_week) % 7
local next_tuesday_time = current_time + days_until_tuesday *
local retval="UNDEFINED"
▲ local next_tuesday_time = current_time + days_until_tuesday * 86400 -- 86400 seconds in a day
if isodate == "true" and current_day_of_week == 2 then
elseif current_day_of_week == 2 then
retval
elseif isodate == true then
else
▲ return os.date("%Y-%m-%d", next_tuesday_time)
end
return retval
end
|