Jump to content

Module:Japanese calendar

Permanently protected module
From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Mr. Stradivarius (talk | contribs) at 20:37, 20 August 2013 (make a start on this). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
(diff) ← Previous revision | Latest revision (diff) | Newer revision → (diff)

local p = {}

local function getEraName( year )
    local eras = mw.loadData( 'Module:Japanese calendar/data' )
    local currentYear = tonumber( mw.language.getContentLanguage():formatDate( 'Y' ) )
    if year > currentYear then return end
    for i, t in ipairs( eras ) do
        if year > t.year then
            return t.era
        end
    end
end

function p.main( frame )
    local year = type( frame ) == 'table' and type( frame.args == 'table' ) and frame.args[ 1 ] or frame
    return getEraName( year )
end

return p