Content deleted Content added
validate parameters if warnings=1 in template; simplify message and generalize category; accept range=no with generic templates to help emulate inconsistent {{age in years nts}} |
more camelCase |
||
Line 1:
-- Implement various "age of" and other date-related templates.
local _Date,
local function getExports(frame)
-- Return objects exported from the date module or its sandbox.
Line 8:
local datemod = require('Module:Date' .. sandbox)
_Date = datemod._Date
end
return _Date,
end
Line 160:
ymw = { 'y', 'm', 'w', id = 'ymw' },
ymwd = { 'y', 'm', 'w', 'd', id = 'ymwd' },
yd = { 'y', 'd', id = 'yd',
m = { 'm', id = 'm' },
md = { 'm', 'd', id = 'md' },
Line 239:
-- v is a number (say 4 for 4 years), or a table ({4,5} for 4 or 5 years).
local islist = type(v) == 'table'
if (islist or v > 0) or (text.n == 0 and i == count) or (text.n > 0 and components.
local fmt, vstr
if i == 1 and options.format == 'format_commas' then
Line 367:
defaultJoin = 'sep_space'
abbr = 'abbr_raw'
elseif parms.
defaultJoin = 'sep_serialcomma'
end
local diffOptions = {
round = parms.round,
duration = parms.
range = parms.range and true or nil,
}
local prefix
if parms.sortable then
local value = diff.age_days + (parms.
if diff.isnegative then
value = -value
Line 407:
-- * text (a string error message)
-- A missing date is replaced with the current date.
-- If
-- from the current date, so can get a bizarre mixture of
-- specified/current y/m/d as has been done by some "age" templates.
Line 439:
end
end
local
local dates = {}
if isNamed or imax >= 3 then
local nrDates = getopt.single and 1 or 2
if getopt.
-- Cannot be partial since empty fields are set from current.
local components = { 'year', 'month', 'day' }
Line 459:
if (partial and y) or (y and m and d) then
dates[i] = Date(fix, partial, y, m, d)
elseif not y and not m and not d and not
dates[i] = Date('currentdate')
end
end
end
elseif not
getopt.textdates = true -- have parsed each date from a single text field
dates[1] = Date(fix, partial, fields[1] or 'currentdate')
Line 581:
age_ymwd = { -- {{age in years, months, weeks and days}}
show = 'ymwd',
},
}
Line 612:
range = range,
partial = spec.partial or spec.range,
}
local date1, date2 = getDates(frame, getopt)
Line 626:
local parms = {
diff = date2 - date1,
range = range,
show = args.show == 'hide' and 'hide' or spec.show,
abbr = spec.abbr,
Line 646:
-- Implement [[Template:Birth date and age]].
local args = frame:getParent().args
local options = {
local date = getDates(frame, options)
if type(date) == 'string' then
Line 722:
-- The returned value is negative for dates before 1 January 1 AD
-- despite the fact that GSD is not defined for such dates.
local date = getDates(frame, {
if type(date) == 'string' then
return date
Line 763:
local args = frame:getParent().args
local parms = {
range = yes(args.range) or (args.range == 'dash' and 'dash' or nil),
}
local fix = yes(args.fix) and 'fix' or ''
|