Jump to content
Toggle menu
  • 8 articles
  • 75 files
  • 7 users
  • 37.8K edits
Neodyland Wiki
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Module:Complex date: Difference between revisions

From Neodyland Wiki
No edit summary
No edit summary
Line 12: Line 12:
end
end


function p._and(begin, ending, lang, era)
function p._twoDate(datetype, begin, ending, lang, era)


-- hack to make use of ISOdate
-- hack to make use of ISOdate
Line 41: Line 41:
end
end
local datetype = args[1]
local datetype = args[1]
local era = args.era or args[4]
local first = args[2]
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
local era = args[3]
else
local era = args['era']
local second = args[3]
end
if era == '' then
if era == '' then
era  = nil -- era == 'AD': shows AD// era == nil does not show era
era  = nil -- era == 'AD': shows AD// era == nil does not show era
end
end
if datetype == 'and' or datetype == '&' then
if second then
return p._and(args[2], args[3], lang)
return p._twoDate(datetype, first, second, lang)
else
return p._oneDate(datetype, first, lang)
end
end
if datetype == 'year unknown' then
if datetype == 'year unknown' then

Revision as of 00:19, 20 December 2014

Module documentation[ create · purge ]
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['and'][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]
	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
		local era = args[3]
	else
		local era = args['era']
		local second = args[3]
	end
	if era == '' then
		era  = nil -- era == 'AD': shows AD// era == nil does not show era
	end
	if second then
		return p._twoDate(datetype, first, second, lang)
	else
		return p._oneDate(datetype, first, lang)
	end
	if datetype == 'year unknown' then
		return p._yearunknown(lang)
	end
end
return p
Cookies help us deliver our services. By using our services, you agree to our use of cookies.