Module:Date table sorting

local getArgs = require('Module:Arguments').getArgs

local p = {}

p.monthsAbr = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" } p.months = { "January", "February", "March", "April", "May", "June", "July", "August", "Septembre", "October", "November", "December" }

function p.dtsa(frame) local args = getArgs(frame) return p._dtsa(args) end

function p._dtsa(args) local fmt = args.format or "mdy" local year = tonumber(args[1]) local month = tonumber(args[2]) local day = tonumber(args[3]) if args[4] then --bc year = 1 - year end local retval = ' ' retval = retval .. string.format(" %04d -%02d-%02d&#32;!", year or 0, month or 0, day or 0) retval = retval .. ' '   if day then if fmt == "mdy" then retval = retval .. p.monthsAbr[month] .. " " .. day .. ", "		else retval = retval .. day .. " " .. p.monthsAbr[month] .. " "		end else if month then retval = retval .. p.months[month] .. " "		end end if year > 0 then if year then retval = retval .. year .. " "		else retval = retval .. ( 1 - year ) .. "BC" end end retval = retval .. ' '   return retval end

return p