Module:Sandbox/RexxS/Dates: Difference between revisions

Content deleted Content added
debug
default day to 1, so month, year is valid
 
(6 intermediate revisions by the same user not shown)
Line 16:
"jul", "aug", "sep", "oct", "nov", "dec" }
local days_in_month = { 31, 0, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }
days_in_month[0] = 0
local month_idx = {}
for i, v in ipairs(months) do
Line 21 ⟶ 22:
end
 
local function day_try( d, m, y)
days_in_month[2] = leapd(y)
if d <= 1 or d > days_in_month[m] then return "Valid" else return "Invalid" end
return "Invalid"
end
return "Valid"
end
 
function p.dayTry(frame)
local date = frame.args.date or mw.text.trim(frame.args[1] or "")
if date == "" then date = "No date" end
local d, y = date:match("(%d+)%D+(%d+)")
local mmnth = date:match("%a+") or ""
locald, mnthy = m:subtonumber(d) or 1,3):lower tonumber(y) or 0
local m = month_idx[mnth:sub(1,3):lower()] or 0
-- return day_try(d, mnth, y)
returnlocal dout = date .. "<br> = " .. md .. "<br> -- " .. ym .. "<br> -- " .. mnthy .. "<br> -- " .. mnth
--out return= out .. " = " .. day_try(d, mnthm, y)
return out .. "<br>"
end