Module:YMD to ISO: Difference between revisions

simplify month_number (instead of a separate test, `sept` can simply be added as an entry to the months_abbr array)
m (1 revision imported)
(simplify month_number (instead of a separate test, `sept` can simply be added as an entry to the months_abbr array))
Line 3: Line 3:
local function month_number(month_name)
local function month_number(month_name)
     local months_full = {january=1, february=2, march=3, april=4, may=5, june=6, july=7, august=8, september=9, october=10, november=11, december=12}
     local months_full = {january=1, february=2, march=3, april=4, may=5, june=6, july=7, august=8, september=9, october=10, november=11, december=12}
     local months_abbr = {jan=1, feb=2, mar=3, apr=4, may=5, jun=6, jul=7, aug=8, sep=9, oct=10, nov=11, dec=12}
     local months_abbr = {jan=1, feb=2, mar=3, apr=4, may=5, jun=6, jul=7, aug=8, sep=9, sept=9, oct=10, nov=11, dec=12}
     local month_lc, _ = string.gsub(string.lower(month_name),'%.','',1)
     local month_lc, _ = string.gsub(string.lower(month_name),'%.','',1)
     local month_num = months_full[month_lc] or months_abbr[month_lc] or 0
     local month_num = months_full[month_lc] or months_abbr[month_lc] or 0
    if month_lc == 'sept' then
        month_num = 9
    end
     return month_num
     return month_num
end
end
Anonymous user