Module:Sandbox/RexxS/Dates: Difference between revisions

Content deleted Content added
test functions related to dates
 
extract month number
Line 4:
 
local p = {}
 
 
local function leapd(y)
Line 12 ⟶ 13:
end
 
local months = { "jan", "feb", "mar", "apr", "may", "jun",
"jul", "aug", "sep", "oct", "nov", "dec" }
local days_in_month = { 31, leapd(y), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }
local month_idx = {}
for i, v in ipairs(months) do
month_idx[v] = i
end
 
local function day_try( d, m, y)
Line 20 ⟶ 27:
function p.dayTry(frame)
local date = frame.args.date or mw.text.trim(frame.args[1] or "")
local d, y, m = date:match("(%d+)%D+(%d+)"), date:match("%a+") or ""
local mnth = m:sub(1,3):lower()
return day_try(d, mmnth, y)
end
 
 
return p