Module:DayCalc: Difference between revisions

Fixing up the get_next_tuesday logic and made it use an offset so that the date calculation uses Pacific Standard Time
(Temporary change)
(Fixing up the get_next_tuesday logic and made it use an offset so that the date calculation uses Pacific Standard Time)
 
(One intermediate revision by the same user not shown)
Line 5:
function p.get_next_tuesday(frame)
local isodate = frame.args.isodate
local current_timepst_tzoffset = os.time0 - ( 8 * 60 * 60 )
local current_time = os.time() + pst_tzoffset
local current_day_of_week = tonumber(os.date("%w", current_time))
local days_until_tuesday = (79 - current_day_of_week) % 7
local next_tuesday_time = current_time + days_until_tuesday * 8640024 --* 8640060 seconds* in a day60
local retval="2023-12-19UNDEFINED"
local next_tuesday_time = current_time + days_until_tuesday * 86400 -- 86400 seconds in a day
 
local retval="2023-12-19"
if isodate == "true" and current_day_of_week == 2 then
ifretval isodate == os.date("true%Y-%m-%d", thencurrent_time)
elseif current_day_of_week == 2 then
retval = os.date("%Y-%m-B %d, %Y", current_time)
else
elseif isodate == true then
retval=os.date("%B %d, %Y", current_time)
retval = retval=os.date("%Y-%m-%d", next_tuesday_time)
end
else
if isodateretval == os.date("true%B %d, %Y", thennext_tuesday_time)
retval=os.date("%Y-%m-%d", next_tuesday_time)
else
retval=os.date("%B %d, %Y", next_tuesday_time)
end
end
local retval="2023-12-19"
return retval
end