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

From Neodyland Wiki
Revision as of 11:07, 2 December 2014 by commons>Zolo (Created page with 'local p = {} local era = require('Module:Era') local i18n = require('Module:i18n/era') local langSwitch = require('Module:Fallback')._langSwitch local maintenan...')
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
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/era')
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 anddate(begin, ending, lang, era)
	
	-- hack to make use of ISOdate
	local frame = {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 era = args.era or args[3]
	if era == '' then
		era  = nil -- era == 'AD': shows AD// era == nil does not show era
	end
	if datettype =='and' then
		return p._and(args[1], args[2], 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.