Used for formatting ranges of dates. Can accept an unlimited number of start/end pairs. It will automatically truncate the end date to the last two digits if the rest of the digits match. If the end date is missing, the range will be presented with just the start date (or you can set the end date to "present").
This template formats many year ranges in a way that is not in compliance with the guideline at MOS:YEARRANGE. In nearly all cases, year ranges should be in the form YYYY–YYYY, not YYYY–YY. Two-digit ending years are allowed only in limited circumstances.
{{
#invoke:Daterange|main|1997|2002}}
→ 1997–2002
{{
#invoke:Daterange|main|1997|present}}
→ 1997–present
{{
#invoke:Daterange|main|1997|‍}}
→1997–
{{
#invoke:Daterange|main|start=2020|end=2002}}
→ 2020–22 (usually not valid per
MOS:YEARRANGE)
{{
#invoke:Daterange|main|start1=1997|end1=2002|start2=2020|end2=2022|start3=2023}}
→ 1997–2002, 2020–22, 2023 (not valid per
MOS:YEARRANGE)
If you wish to show an open-ended range, use 1997–
The module will not handle non-sequential parameters, so if you have {{{start1}}}
, {{{start2}}}
, and {{{start4}}}
, only {{{start1}}}
and {{{start2}}}
will be used.
return { main = function(frame)
local args = require('Module:Arguments').getArgs(frame)
local output = {}
for k, v in pairs(args) do
if (type(k) == "string") and ((v or "") ~= "") and (k:sub(0,5) == "start") and tonumber(k:sub(6,-1)) then
num = tonumber(k:sub(6,-1))
if num and num > 0 then
e = args"end"..num or ""
if e:sub(0,-3) == v:sub(0,-3) then
e = e:sub(-2,-1)
end
outputnum = v..(e~="" and "–"..e or "")
end
end
end
s = (args.start or args1 or "")
if (s ~= "") then
e = args"end" or args2 or ""
if e:sub(0,-3) == s:sub(0,-3) then
e = e:sub(-2,-1)
end
table.insert(output, 1, s..(e~="" and "–"..e or ""))
end
return table.concat(output, ", ")
end }
Used for formatting ranges of dates. Can accept an unlimited number of start/end pairs. It will automatically truncate the end date to the last two digits if the rest of the digits match. If the end date is missing, the range will be presented with just the start date (or you can set the end date to "present").
This template formats many year ranges in a way that is not in compliance with the guideline at MOS:YEARRANGE. In nearly all cases, year ranges should be in the form YYYY–YYYY, not YYYY–YY. Two-digit ending years are allowed only in limited circumstances.
{{
#invoke:Daterange|main|1997|2002}}
→ 1997–2002
{{
#invoke:Daterange|main|1997|present}}
→ 1997–present
{{
#invoke:Daterange|main|1997|‍}}
→1997–
{{
#invoke:Daterange|main|start=2020|end=2002}}
→ 2020–22 (usually not valid per
MOS:YEARRANGE)
{{
#invoke:Daterange|main|start1=1997|end1=2002|start2=2020|end2=2022|start3=2023}}
→ 1997–2002, 2020–22, 2023 (not valid per
MOS:YEARRANGE)
If you wish to show an open-ended range, use 1997–
The module will not handle non-sequential parameters, so if you have {{{start1}}}
, {{{start2}}}
, and {{{start4}}}
, only {{{start1}}}
and {{{start2}}}
will be used.
return { main = function(frame)
local args = require('Module:Arguments').getArgs(frame)
local output = {}
for k, v in pairs(args) do
if (type(k) == "string") and ((v or "") ~= "") and (k:sub(0,5) == "start") and tonumber(k:sub(6,-1)) then
num = tonumber(k:sub(6,-1))
if num and num > 0 then
e = args"end"..num or ""
if e:sub(0,-3) == v:sub(0,-3) then
e = e:sub(-2,-1)
end
outputnum = v..(e~="" and "–"..e or "")
end
end
end
s = (args.start or args1 or "")
if (s ~= "") then
e = args"end" or args2 or ""
if e:sub(0,-3) == s:sub(0,-3) then
e = e:sub(-2,-1)
end
table.insert(output, 1, s..(e~="" and "–"..e or ""))
end
return table.concat(output, ", ")
end }