{ '酉', 'Rooster' }, -- 10
{ '戌', 'Dog' }, -- 11
{ '亥', 'Pig' } -- 12
}  
-- Calculate the cycle numbers from the year. The first sexagenary year corresponds to the *previous* year's entry
-- in Chinese calendar correspondence table, as the Chinese New Year doesn't happen until Jan/Feb in
-- Gregorian years.
local sexagenaryYear1 = ( year - 4 ) % 60
local sexagenaryYear2 = ( year - 3 ) % 60
local heavenlyNum1 = (sexagenaryYear1 - 1) % 10 + 1 -- amod, since lua arrays are 1-indexed
local heavenlyNum2 = (sexagenaryYear2 - 1) % 10 + 1
local earthlyNum1 = (sexagenaryYear1 - 1) % 12 + 1
local earthlyNum2 = (sexagenaryYear2 - 1) % 12 + 1  
-- Get the data tables for each permutation.
local heavenlyTable1 = heavenlyStems[ heavenlyNum1 ]
local heavenlyTable2 = heavenlyStems[ heavenlyNum2 ]
local earthlyTable1 = earthlyBranches[ earthlyNum1 ]
local earthlyTable2 = earthlyBranches[ earthlyNum2 ]  
-- Work out the continously-numbered year. (See Chinese calendar#Continuously numbered years.)
local year1 = year + 2696
local year2 = year + 2697
local year1Alt = year1 - 60
local year2Alt = year2 - 60  
-- Format any negative numbers.
year1 = formatNegative( tostring( year1 ) )
year2 = formatNegative( tostring( year2 ) )
year1Alt = formatNegative( tostring( year1Alt ) )
year2Alt = formatNegative( tostring( year2Alt ) )  
-- Return all of that data in a (hopefully) reader-friendly format.
chinese:setYear( string.format(
[=%s%s年 (%s&nbsp;%s)
%s or %s
&nbsp;&nbsp;&nbsp;&nbsp;*—&nbsp;to&nbsp;—*
%s%s年 (%s&nbsp;%s)
%s or %s]=],
heavenlyTable1[ 1 ],
earthlyTable1[ 1 ],
heavenlyTable1[ 2 ],
earthlyTable1[ 2 ],
year1,
year1Alt,
heavenlyTable2[ 1 ],
earthlyTable2[ 1 ],
heavenlyTable2[ 2 ],
earthlyTable2[ 2 ],
year2,
year2Alt
) )  
box:addCalendar( chinese )  
---
-- Coptic calendar
---  
local coptic = calendar:new
coptic:setLink( 'Coptic calendar' )
coptic:setYearRange( year - 284, year - 283 )
box:addCalendar( coptic )  
---
-- Discordian calendar
---  
local discordian = calendar:new
discordian:setLink( 'Discordian calendar' )
discordian:setYear( year + 1166 )
box:addCalendar( discordian )  
---
-- Ethiopian calendar
---  
local ethiopian = calendar:new
ethiopian:setLink( 'Ethiopian calendar' )
ethiopian:setYearRange( year - 8, year - 7 )
box:addCalendar( ethiopian )  
---
-- Hebrew calendar
---  
local hebrew = calendar:new
hebrew:setLink( 'எபிரேய நாட்காட்டி' )
hebrew:setYearRange( year + 3760, year + 3761 )
box:addCalendar( hebrew )  
---
-- Hindu calendars
---  
local hindu = calendarGroup:new{ heading = 'இந்து நாட்காட்டிகள்' }  
-- Vikram Samvat  
local vikramSamvat = calendar:new
vikramSamvat:setLink( 'விக்ரம் நாட்காட்டி' )
vikramSamvat:setYearRange( year + 56, year + 57 )
hindu:addCalendar( vikramSamvat )  
-- Shaka Samvat  
local shakaSamvat = calendar:new
shakaSamvat:setLink( 'இந்தியத் தேசிய நாட்காட்டி', 'சக சம்வாட்' )
if year >= 78 then
shakaSamvat:setYearRange( year - 79, year - 78 )
end
hindu:addCalendar( shakaSamvat )  
-- Kali Yuga  
local kaliYuga = calendar:new
kaliYuga:setLink( 'கலி யுகம்' ) -- use italics
kaliYuga:setYearRange( year + 3100, year + 3101 )
hindu:addCalendar( kaliYuga )  
box:addCalendarGroup( hindu )  
---
-- Holocene calendar
---  
local holocene = calendar:new
holocene:setLink( 'Holocene calendar' )
holocene:setYear( year + 10000 )
box:addCalendar( holocene )  
---
-- Igbo calendar
---  
-- In the old template this was a calendar group with just one calendar; intentionally adding this as a single
-- calendar here, as the previous behaviour looked like a mistake.
if year >= 1000 then
local igbo = calendar:new
igbo:setLink( 'Igbo calendar' )
igbo:setYearRange( year - 1000, year - 999 )
box:addCalendar( igbo )
end  
---
-- Iranian calendar
---  
local iranian = calendar:new
iranian:setLink( 'இரானிய நாட்காட்டிகள்', 'இரானிய நாட்காட்டி' )
if year - 621 > 0 then
iranian:setYearRange( year - 622, year - 621 )
else
iranian:setYear( string.format( '%d BP&nbsp;– %d BP', 622 - year, 621 - year ) )
end
box:addCalendar( iranian )  
---
-- Islamic calendar
---  
local islamic = calendar:new
islamic:setLink( 'இசுலாமிய நாட்காட்டி' )
local islamicMult = 1.030684 -- the factor to multiply by
local islamicSub = 621.5643 -- the factor to subtract by
if year - 621 > 0 then
local year1 = math.floor( islamicMult * ( year - islamicSub ) )
local year2 = math.floor( islamicMult * ( year - islamicSub + 1 ) )
islamic:setYearRange( year1, year2 )
else
local year1 = math.ceil( -islamicMult * ( year - islamicSub ) )
local year2 = math.ceil( -islamicMult * ( year - islamicSub + 1 ) )
islamic:setYear( string.format( '%d BH&nbsp;– %d BH', year1, year2 ) )
end
box:addCalendar( islamic )  
---
-- Japanese calendar
-- starting 600
---  
if year >= 600 then
local japanese = calendar:new
japanese:setLink( 'சப்பானிய நாட்காட்டி' )  
japanese.thisEra = japaneseEra:new{ year = year }
if japanese.thisEra then
local japaneseYearText = {}
japanese.oldEra = japanese.thisEra:getOldEra
if japanese.oldEra and japanese.oldEra.eraYear and japanese.thisEra.article ~= japanese.oldEra.article then
japanese.oldText = string.format( '%s %d', japanese.oldEra.link, japanese.oldEra.eraYear )
table.insert( japaneseYearText, japanese.oldText )
table.insert( japaneseYearText, ' / ' )
end
if japanese.thisEra.eraYear then
table.insert( japaneseYearText, string.format( '%s %d', japanese.thisEra.link, japanese.thisEra.eraYear ) )
end
table.insert( japaneseYearText, string.format( '
(%s%s年)', japanese.thisEra.kanji, japanese.thisEra.eraYearKanji ) )
japanese:setYear( table.concat( japaneseYearText ) )
end  
box:addCalendar( japanese )
end  
---
-- Javanese calendar
---  
local javanese = calendar:new
javanese:setLink( 'Javanese calendar' )
local javaneseMult = 1.030684 -- the factor to multiply by
local javaneseSub = 124.9 -- the factor to subtract by
if year - 124 > 0 then
local year1 = math.floor( javaneseMult * ( year - javaneseSub ) )
local year2 = math.floor( javaneseMult * ( year - javaneseSub + 1 ) )
javanese:setYearRange( year1, year2 )
else
local year1 = math.ceil( -javaneseMult * ( year - javaneseSub ) )
local year2 = math.ceil( -javaneseMult * ( year - javaneseSub + 1 ) )
end
box:addCalendar( javanese )  
---
-- Juche calendar
-- displays only after 1910
---  
if year >= 1910 then
local juche = calendar:new
juche:setLink( 'Juche calendar' )
if year > 1911 then
juche:setYear( year - 1911 )
end
box:addCalendar( juche )
end  
---
-- Julian calendar
---  
local julian = calendar:new
julian:setLink( 'யூலியன் நாட்காட்டி' )  
if year >= -45 and year < 1582 then
julian:setYear(gregorian.year)
elseif year >= 1582 then
local diff = math.floor(year/100-2) - math.floor(year/400)
if year % 100 == 0 and year % 400 ~= 0 then
julian:setYear('Gregorian minus ' .. diff-1 .. ' or ' .. diff .. ' days')
else
julian:setYear('Gregorian minus ' .. diff .. ' days')
end
end  
box:addCalendar( julian )  
---
-- Korean calendar
---  
local korean = calendar:new
korean:setLink( 'கொரியன் நாட்காட்டி' )
korean:setYear( year + 2333 )
box:addCalendar( korean )  
---
-- Minguo calendar
---  
local minguo = calendar:new
minguo:setLink( 'Minguo calendar' )
if year > 1949 then
local minguoYear = year - 1911
minguo:setYear( string.format( 'ROC %d
民國%d年', minguoYear, minguoYear ) )
elseif year > 1911 then
local minguoYear = year - 1911
minguo:setYear( string.format( 'ROC %d
民國%d年', minguoYear, minguoYear ) )
else
local minguoYear = 1911 - year + 1
minguo:setYear( string.format( '%d before ROC
民前%d年', minguoYear, minguoYear ) )
end
box:addCalendar( minguo )  
---
-- Nanakshahi calendar
---  
local nanakshahi = calendar:new
nanakshahi:setLink( 'Nanakshahi calendar' )
nanakshahi:setYear( year - 1468 )
box:addCalendar( nanakshahi )  
---
-- Seleucid era
-- displays from 312 BC until 1200 AD
---  
if year >= -311 and year < 1200 then
local seleucid = calendar:new
seleucid:setLink( 'Seleucid era' )
local addtext = string.format( 'AG')
seleucid:setYearCouple( year + 311, year + 312, addtext )
box:addCalendar( seleucid )
end  
---