local p =
local function leapd(y) if y % 1000
0 then return 28 end if y% 4
local months = local days_in_month = days_in_month[0] = 0local month_idx = for i, v in ipairs(months) do month_idx[v] = iend
local function day_try(d, m, y) days_in_month[2] = leapd(y) if tonumber(d) < 1 or tonumber(d) > days_in_month[m] then return "Invalid" end return "Valid"end
local function day_or_mon_year(thing) if tonumber(thing)>31 then return "year" else if tonumber(thing)
local function iso_month(thing) if thing
"02" then return "February" else return thing end if thing
"04" then return "April" else return thing end if thing
"06" then return "June" else return thing end if thing
"08" then return "August" else return thing end if thing
"10" then return "October" else return thing end if thing
"12" then return "December" else return thing endend local function month_edit(thing) local count=1 local count2=1 local count3=1 local count4=1 local months = local month1_idx = for i, v in ipairs(months) do month1_idx[v] = i end local months2= local month2_idx = for i, v in ipairs(months2) do month2_idx[v] = i end local month3_idx = local months3= for i, v in ipairs(months3) do month3_idx[v] = i end local month4_idx = local months4= for i, v in ipairs(months4) do month4_idx[v] = i end for i=1,12 do if thing
months2[i] then count3=count3+1 end end for i=1,12 do if thing
months4[i] then count4=count4+1 end end if count
1 then if count2
1 then if count3
1 then if count4
local function iso_edit(num) if tonumber(num)<10 then return "0"..num else return num end end p.unpackdate = function(frame) local dmydate = frame.args.dmydate or "" local formatdate = frame.args.formatdate or "" local months = local months2= local months4= local months3= local month_idx = for i, v in ipairs(months3) do month_idx[v] = i end local special_year= local around= local year="" local month="" local day="" local special="" local appro="" local num1,num2,num3 numbers = for num in string.gmatch(dmydate, "%d+") do numbers[#numbers + 1] = num end strings = for stringss in string.gmatch(dmydate, "%a+") do strings[#strings + 1] = stringss end for i=1,#strings do for i2=1,4 do if strings[i]
around[i2] then appro="circa".." " end end end for i=1,#strings do for i2=1,12 do if strings[i]
months2[i2] then month=strings[i] end end for i2=1,12 do if strings[i]
months4[i2] then month=strings[i] end end end if(#numbers
3) then if tonumber(numbers[1])>31 then year = numbers[1].." "..special day = numbers[3] month=numbers[2] else if special
"01" then month ="January" end if month
"03" then month ="March" end if month
"05" then month ="May" end if month
"07" then month= "July" end if month
"09" then month= "September" end if month
"11" then month= "November" end if month
2 and month
0) then if tonumber(numbers[1])>31 then year = numbers[1].." "..special day = numbers[2] else year = numbers[2].." "..special day = numbers[1] return appro..year..special end end if(#numbers
"" and #strings>0) then return "invalid entry" end if(#numbers
3 and formatdate
"") then formatdate="dym" end if(#numbers
"") then return appro..numbers[1].." "..special end if(#numbers
1) then return appro..numbers[1].." "..strings[1]..special end if(formatdate
2 then if day_try(day, month_idx[month_edit(month)], year)
"mdy") then if month_idx[month_edit(month)]
"Invalid" then return "invalid entry" else return appro..month_edit(month).." "..day..","..year..special end else return appro..month_edit(month).." "..day..","..year..special end end if(formatdate
2 then if day_try(day, month_idx[month_edit(month)], year)
"year") then if month_idx[month_edit(month)]
"Invalid" then return "invalid entry" else return appro..year..special end else return appro..year..special end end if(formatdate
"Invalid" then return "invalid entry" else return appro..month_edit(month).." "..year end end endreturn p