Module:Year in various calendars: Difference between revisions
Content added Content deleted
Vivaporius (talk | contribs) m (1 revision imported) |
en>Centrist16 (Created page with "-- Load dependencies. local getArgs = require('Module:Arguments').getArgs local numToRoman = require( 'Module:Roman' ).main local getOlympiad = require( 'Module:Ancient Olympiads' )._main local getDynasty = require( 'Module:Ancient Egypt era' )._main local getPharaoh = require( 'Module:Ancient Egypt kings' )._main local numToArmenian = require( 'Module:Armenian' ).main local getRegnal = require( 'Module:British regnal year' ).main local japaneseEra = require( 'Module:Jap...") |
||
Line 134: | Line 134: | ||
self.caption = self.yearText |
self.caption = self.yearText |
||
self.footnotes = init.footnotes |
self.footnotes = init.footnotes |
||
self.navbar = init.navbar |
|||
return setmetatable( obj, { |
return setmetatable( obj, { |
||
Line 189: | Line 188: | ||
:attr( 'colspan', '2' ) |
:attr( 'colspan', '2' ) |
||
:wikitext( string.format( '<small>%s</small>', self.footnotes ) ) |
:wikitext( string.format( '<small>%s</small>', self.footnotes ) ) |
||
end |
|||
-- Add navbar. |
|||
if type( self.navbar ) == 'string' and self.navbar ~= '' then |
|||
root |
|||
:tag( 'tr' ) |
|||
:tag( 'td' ) |
|||
:attr( 'colspan', '2' ) |
|||
:css( 'text-align', 'center' ) |
|||
:wikitext( require('Module:Navbar')._navbar{ self.navbar } ) |
|||
end |
end |
||
Line 376: | Line 365: | ||
-- Initiate the box and get the year values. |
-- Initiate the box and get the year values. |
||
local init = args |
local init = args |
||
init.navbar = 'Year in various calendars' |
|||
local box = calendarBox:new( init ) |
local box = calendarBox:new( init ) |
||
local year = box.year |
local year = box.year |
||
Line 506: | Line 494: | ||
if year >= 1844 then |
if year >= 1844 then |
||
local bahai = calendar:new() |
local bahai = calendar:new() |
||
bahai:setLink( " |
bahai:setLink( "Baháʼí calendar" ) |
||
bahai:setYearRange( year - 1844, year - 1843 ) |
bahai:setYearRange( year - 1844, year - 1843 ) |
||
box:addCalendar( bahai ) |
box:addCalendar( bahai ) |
||
Line 651: | Line 639: | ||
-- Return all of that data in a (hopefully) reader-friendly format. |
-- Return all of that data in a (hopefully) reader-friendly format. |
||
chinese:setYear( string.format( |
chinese:setYear( string.format( |
||
[=[[[ |
[=[[[Sexagenary cycle|%s%s]]年 <small>(%s %s)</small><br />%s or %s<br /> ''— to —''<br />%s%s年 <small>(%s %s)</small><br />%s or %s]=], |
||
heavenlyTable1[ 1 ], |
heavenlyTable1[ 1 ], |
||
earthlyTable1[ 1 ], |
earthlyTable1[ 1 ], |
||
Line 842: | Line 830: | ||
if year >= 1910 then |
if year >= 1910 then |
||
local juche = calendar:new() |
local juche = calendar:new() |
||
juche:setLink( |
juche:setLink( 'Juche calendar' ) |
||
if year > 1911 then |
if year > 1911 then |
||
juche:setYear( year - 1911 ) |
juche:setYear( year - 1911 ) |
||
Line 1,032: | Line 1,020: | ||
local function getUnixTime( year ) |
local function getUnixTime( year ) |
||
if year < 1970 then return end |
if year < 1970 then return end |
||
if year > 2039 then return end |
|||
if year == 2039 then |
|||
-- Y2K38 bug |
|||
return "[[Year 2038 problem|-2117492897]]" |
|||
end |
|||
local noError, unixTime = pcall( lang.formatDate, lang, 'U', '1 Jan ' .. tostring( year ) ) |
local noError, unixTime = pcall( lang.formatDate, lang, 'U', '1 Jan ' .. tostring( year ) ) |
||
if not noError or noError and not unixTime then return end |
if not noError or noError and not unixTime then return end |