Module:Sandbox/MrSpecjal/Dates explained

p =

p.extractDate = function (frame) local date = frame.args.date or "invalid value" local format = frame.args.format or "recognize format" local output = "" if(date

"invalid value") then output = "Your input date is invalid" return output end local day, month, year = string.match(date, "(%d+) (%w+) (%d+)") if day

nil then day = 1 end if month

nil then month = Invalid end if year

nil then year = 2018 end output = "Year = " .. year .. "
Day = " .. day .. "
Month = ".. month return outputend

p.checkDate = function (frame) local us_mdY = frame.args.us_mdY local m, d, Y = us_mdY:match("(%d+)/(%d+)/(%d+)") local epoch = os.time local zeromdy = string.format("%02d/%02d/%04d", m, d, Y) return zeromdy

os.date('%m/%d/%Y', epoch)end

p.isValidDate = function (frame) local us_mdY = frame.args.us_mdY local m, d, y = us_mdY:match("(%d+)/(%d+)/(%d+)")

m, d, y = tonumber(m), tonumber(d), tonumber(y)

if d <= 0 or d > 31 or m <= 0 or m > 12 or y <= 0 then -- Cases that don't make sense return false elseif m

4 or m

6 or m

9 or m

11 then -- Apr, Jun, Sep, Nov can have at most 30 days return d <= 30 elseif m

2 then -- Feb if y%400

0 or (y%100 ~= 0 and y%4

0) then -- if leap year, days can be at most 29 return d <= 29 else -- else 28 days is the max return d <= 28 end else -- all other months can have at most 31 days return d <= 31 endend

return p