Module:Complex date: Difference between revisions
From Neodyland Wiki
More actions
No edit summary |
No edit summary |
||
| Line 21: | Line 21: | ||
ending = datemod.ISOdate{frame} | 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 pattern = i18n['and'][lang] -- checks if there is a special case for this and, else use linguistic.conj function | ||
local outputstr | local outputstr | ||
| Line 30: | Line 30: | ||
outputstr = linguistic.conj({begin, ending}, lang) | outputstr = linguistic.conj({begin, ending}, lang) | ||
end | end | ||
return makeera(outputstr, era, lang) | return begin | ||
--- return makeera(outputstr, era, lang) | |||
end | end | ||
| Line 45: | Line 46: | ||
end | end | ||
if datetype == 'and' or datetype == '&' then | if datetype == 'and' or datetype == '&' then | ||
return p._and(args[2], args[3], lang) | |||
end | end | ||
if datetype == 'year unknown' then | if datetype == 'year unknown' then | ||
Revision as of 03:17, 19 December 2014
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 p._and(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 begin
--- 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[4]
if era == '' then
era = nil -- era == 'AD': shows AD// era == nil does not show era
end
if datetype == 'and' or datetype == '&' then
return p._and(args[2], args[3], lang)
end
if datetype == 'year unknown' then
return p._yearunknown(lang)
end
end
return p