local p =
local function month_number(month_name) local months_full = local months_abbr = local month_lc, _ = string.gsub(string.lower(month_name),'%.',,1) local month_num = months_full[month_lc] or months_abbr[month_lc] or 0 return month_numend
local function days_in_month(month_num,year) -- modified from code in Module:Citation/CS1/Date_validation local days = local month_length if month_num
0 then month_length = 29 -- if leap year, then 29 days end else -- Gregorian calendar since Oct 1582 if ((year%4)
0)) then month_length = 29 -- if leap year, then 29 days end end else -- not February, get number of days for month month_length = days[month_num] end return month_lengthend
local function zero_pad(string) if string.len(string)
function p.main(frame) if frame.args[1]
then return -- first argument is empty end if not arg1:match('^%d%d%d%d %a%a%a%a?%.?%a?%a?%a?%a?%a?%a? *%d%d?$') then return arg1 -- invalid date pattern end local year, month_name, day = string.match(arg1, '^(%d%d%d%d) *(%a%a%a%a?%.?%a?%a?%a?%a?%a?%a?) *(%d%d?)$') if month_number(month_name)
return p