Module:Age: Difference between revisions
From Savez
output nothing for Template:Birth_date_and_age + Template:Death_date_and_age if 'YYYY' is first parameter to avoid TemplateData auto value errors from Template:Infobox_musical_artist
BalkanMapper (talk | contribs) m (1 revision imported) |
death date and age/infobox music genre>Johnuniq (output nothing for Template:Birth_date_and_age + Template:Death_date_and_age if 'YYYY' is first parameter to avoid TemplateData auto value errors from Template:Infobox_musical_artist) |
||
| Line 729: | Line 729: | ||
flag = 'usesCurrent', | flag = 'usesCurrent', | ||
omitZero = true, | omitZero = true, | ||
range = ' | range = 'dash', | ||
}, | }, | ||
age_full_years_nts = { -- {{age nts}} | age_full_years_nts = { -- {{age nts}} | ||
| Line 862: | Line 862: | ||
end | end | ||
return from_en(dateDifference(parms)) | return from_en(dateDifference(parms)) | ||
end | |||
local function isFake(args) | |||
-- Some templates have TemplateData with an auto value like "{{Birth date and age|YYYY|MM|DD}}". | |||
-- Return true if that appears to be the case so the caller can output nothing rather than an error. | |||
return args[1] == 'YYYY' | |||
end | end | ||
| Line 867: | Line 873: | ||
-- Implement [[Template:Birth date and age]]. | -- Implement [[Template:Birth date and age]]. | ||
local args = frame:getParent().args | local args = frame:getParent().args | ||
if isFake(args) then | |||
return '' | |||
end | |||
local options = { | local options = { | ||
missing1 = 'mt-need-valid-bd', | missing1 = 'mt-need-valid-bd', | ||
| Line 940: | Line 949: | ||
-- Implement [[Template:Death date and age]]. | -- Implement [[Template:Death date and age]]. | ||
local args = frame:getParent().args | local args = frame:getParent().args | ||
if isFake(args) then | |||
return '' | |||
end | |||
local options = { | local options = { | ||
missing1 = 'mt-need-valid-dd', | missing1 = 'mt-need-valid-dd', | ||