Module:Infobox/dates
Appearance
![]() | This module depends on the following other modules: |
Usage
{{#invoke:infobox/dates|dates}}
- formats the date range.{{#invoke:infobox/dates|start_end_date_template_validation}}
- checks if the values of|first_aired=
,|released=
,|aired=
,|released_date=
are not passed via{{Start date}}
and if the value of|last_aired=
is not passed via{{End date}}
(or is not|last_aired=present
, where relevant). If they aren't, the function returns the default error category, Category:Pages using infobox television with nonstandard dates or the error category from|error_category=
if used.
local getArgs = require('Module:Arguments').getArgs
local p = {}
function p.dates(frame)
local returnval;
local args = getArgs(frame);
if table.getn(args) < 2 then
if args['1'] == nil and args['2'] == nil then
return '';
elseif args['1'] == nil then
return args['2'];
elseif args['2'] == nil then
return args['1'];
end
end
args['1'] = args['1']:gsub(" "," ");
args['2'] = args['2']:gsub(" "," ");
local dmy = false;
local m1, d1, y1, ex1 = string.match(args['1'], '(%a+)%s(%d+),%s(%d+)(.*)');
local m2, d2, y2, ex2 = string.match(args['2'], '(%a+)%s(%d+),%s(%d+)(.*)');
if y1 == nil then
dmy = true;
d1, m1, y1, ex1 = string.match(args['1'], '(%d+)%s(%a+)%s(%d+)(.*)');
d2, m2, y2, ex2 = string.match(args['2'], '(%d+)%s(%a+)%s(%d+)(.*)');
end
if y1 ~= nil and y2 ~= nil then
ex1 = ex1 or '';
ex2 = ex2 or '';
if y1 == y2 then
if dmy == false then
returnval = m1..' '..d1..ex1..' – '..m2..' '..d2..', '..y2..ex2;
else
returnval = d1..' '..m1..ex1..' – '..d2..' '..m2..' '..y2..ex2;
end
else
if dmy == false then
returnval = m1..' '..d1..', '..y1..ex1..' – '..m2..' '..d2..', '..y2..ex2;
else
returnval = d1..' '..m1..' '..y1..ex1..' – '..d2..' '..m2..' '..y2..ex2;
end
end
else
returnval = args['1']..' – '..args['2'];
end
--return returnval:gsub(" "," ");
return returnval;
end
return p