local p =
p.date_formatting = function(frame) -- Unpacking date local date = frame.args.date or "Invalid entry" local format = frame.args.format or "" months = local year, day = string.match(date, "%D*(%d*)%D*(%d*)%D*") local ans = "" if year ~= "" and day ~= "" then if tonumber(day) > 31 then if tonumber(year) <= 31 then day, year = year, day else ans = "Invalid entry" end end end local k = nil local month = "" for i = 1, #months do k = string.find(date, months[i]) if k
nil then k = string.find(date, string.lower(string.sub(months[i], 1, 1)) .. string.sub(months[i], 2, 3)) end if k
"" and string.find(date, "[-,/]") ~= nil then day, month, year = string.match(date, "(%d+)[-, /](%d+)[-, /](%d+)") right = for i = 1, 12 do if i
0 or (year % 100 ~= 0 and year % 4
a and day
b and day
b and day
c and day
a and day
c and day
"" and day
"" then ans = "Invalid entry" else right = for i = 1, 12 do if i
0 or (year % 100 ~= 0 and year % 4
"" and day ~= "" and year ~= "" and string.find(date, "%a") ~= nil then ans = "Invalid entry" end end --Formatting unpacked date local format_old = "" if day ~= "" and year ~= "" and month ~= "" then if string.find(date, ",") ~= nil then format_old = "mdy" elseif string.find(date, "[-,/]") ~= nil then format_old = "iso" else format_old = "dmy" end elseif year ~= "" and month ~= "" then format_old = "month and year" else format_old = "year" end local u_date = "" local dop = "" if format
"mdy" then u_date = month .. " " .. day .. ", " .. year elseif format
"iso" then u_date = year .. "-" .. months[month] .. "-" .. day elseif format
"month and year" then u_date = month .. " " .. year else u_date = day .. " " .. month .. " " .. year end if string.find(date, "(uncertain)") ~= nil or string.find(date, "around") ~= nil then dop = "circa " end else u_date = ans end return dop .. u_dateendreturn p