Module:Complex date
From Neodyland Wiki
More actions
This documentation is transcluded from Module:Complex date/doc.
local p = {}
local era = require('Module:Era')
local i18n = require('Module:i18n/other date')
local langSwitch = require('Module:Fallback')._langSwitch
local maintenancecat = 'Pages with incorrect usage of Module:Other date'
local datemod = require('Module:Date')
local makeera = require('Module:Era')._era
local linguistic = require('Module:Linguistic')
function yearunknown(lang)
return langSwitch(i18n['yeark unknown'], lang)
end
function p._twoDate(datetype, begin, ending, lang, era)
-- hack to make use of ISOdate
local frame = {}
frame.args = {lang=lang}
frame.args[1] = begin
begin = datemod.ISOdate(frame)
frame.args[1] = ending
ending = datemod.ISOdate(frame)
----
local pattern = i18n[datetype][lang] -- checks if there is a special case for this and, else use linguistic.conj function
local outputstr
if pattern then
outputstr = mw.ustring.gsub(pattern, '$date1', begin)
outputstr = mw.ustring.gsub(outputstr, '$date2', ending)
else
outputstr = linguistic.conj({begin, ending}, lang)
end
return makeera(outputstr, era, lang)
end
function p.otherdate(frame)
local args = frame.args
local lang = frame.args.lang
if not lang or lang == '' then
lang = frame:preprocess('{{int:lang}}')
end
local datetype = args[1]
local first = args[2]
local second
local era
if args[3] == 'BEFORE PRESENT' or args[3] == 'BP' or args[3] == 'BCE' or args[3] == 'BC' or args[3] == 'CE' or args[3] == 'AD' then
era = args[3]
elseif args['era'] ~= '' and args['era'] ~= nil and args[3] ~= nil then
era = args['era']
second = args[3]
else
era = nil
end
if second then
if datetype == '~' or 'ca' or 'circa' then
datetype = 'circa2'
elseif datetype == '&' then
datetype = 'and'
end
return p._twoDate(datetype, first, second, lang)
else
return second, datetype
--return p._oneDate(datetype, first, lang)
end
if datetype == 'year unknown' then
return p._yearunknown(lang)
end
end
return p