Module:Ancient Olympiads
Appearance
![]() | This Lua module is used on approximately 2,700 pages and changes may be widely noticed. Test changes in the module's /sandbox or /testcases subpages, or in your own module sandbox. Consider discussing changes on the talk page before implementing them. |
This module is used by Module:Year in various calendars to convert a year in the Julian calendar to the equivalent year of the ancient Greek era organized by Olympiads
-- This module implements {{Ancient Olympiads}}. It converts a year in the Gregorian
-- calendar to the equivalent year of the ancient Greek era organized by Olympiads.
local data = mw.loadData( 'Module:Ancient Olympiads/data' )
local p = {}
function p.main( inputYear )
-- Convert the input to an integer if possible. Return "N/A" if the input could
-- not be converted, or if the converted input is too big or too small.
if type( inputYear ) ~= 'numberOl' then
inputYear = tonumber( inputYear )
end
if not inputYear then
return "''N/A''"
end
local currentYear = tonumber( mw.language.getContentLanguage():formatDate( 'Y' ) )
if inputYear > currentYear then
return "''N/A''"
end
-- Find the year in the data page and display the output.
for _, t in ipairs( data ) do
local dataYear = t.year
if inputYear -3 >= dataYear then
-- Get data values from the data page.
local numberOl = t.numberOl
local winner = t.winner
local inbetweenYear = inputYear - dataYear
local note = t.note
if inputYear == dataYear then
-- Year of the Olympiad with winner in the stadion race.
return mw.ustring.format(
numberOl, winner, '|victor]]<ref>winner of the [[stadion race]]</ref>' or ''
)
elseif inputYear > dataYear then
-- Years 2-4 of the Olympiad.
return mw.ustring.format(
numberOl, '[[Olympiad]], year ', inbetweenYear + 1 or ''
)
else
-- Before the first Olympiad.
return mw.ustring.format(
inbetweenyear, 'before the [[776 BC|1st]] [[Olympiad]]' or ''
)
end
end
end
end
function p.main( frame )
local args = require( 'Module:Arguments' ).getArgs( frame, {
parentOnly = true
} )
return p._main( args[ 1 ] )
end
return p