Module:DayCalc: Difference between revisions

Content added Content deleted
(Fixed algorithm so that the next "first Tuesday" will be September 5.)
(Temporary change)
Line 7: Line 7:
local current_time = os.time()
local current_time = os.time()
local current_day_of_week = tonumber(os.date("%w", current_time))
local current_day_of_week = tonumber(os.date("%w", current_time))
local days_until_tuesday = (9 - current_day_of_week) % 7
local days_until_tuesday = (7 - current_day_of_week) % 7
local next_tuesday_time = current_time + days_until_tuesday * 86400 -- 86400 seconds in a day
local next_tuesday_time = current_time + days_until_tuesday * 86400 -- 86400 seconds in a day
local retval="2023-12-19"
if current_day_of_week == 2 then
if current_day_of_week == 2 then
if isodate == "true" then
if isodate == "true" then
return os.date("%Y-%m-%d", current_time)
retval=os.date("%Y-%m-%d", current_time)
else
else
return os.date("%B %d, %Y", current_time)
retval=os.date("%B %d, %Y", current_time)
end
end
else
else
if isodate == "true" then
if isodate == "true" then
return os.date("%Y-%m-%d", next_tuesday_time)
retval=os.date("%Y-%m-%d", next_tuesday_time)
else
else
return os.date("%B %d, %Y", next_tuesday_time)
retval=os.date("%B %d, %Y", next_tuesday_time)
end
end
end
end
local retval="2023-12-19"
return retval
end
end