Anonymous user
Module:Citation/CS1/Date validation: Difference between revisions
Module:Citation/CS1/Date validation (view source)
Revision as of 14:43, January 14, 2023
, 1 year agosync from sandbox;
Johnrdorazio (talk | contribs) m (1 revision imported) |
(sync from sandbox;) |
||
Line 627: | Line 627: | ||
if 13 > tonumber(year2) then return false; end -- don't allow 2003-05 which might be May 2003 | if 13 > tonumber(year2) then return false; end -- don't allow 2003-05 which might be May 2003 | ||
year2 = century .. year2; | year2 = century .. year2; -- add the century to year2 for comparisons | ||
if tonumber(year) >= tonumber(year2) then return false; end -- left to right, earlier to later, not the same | if tonumber(year) >= tonumber(year2) then return false; end -- left to right, earlier to later, not the same | ||
if not is_valid_year(year2) then return false; end -- no year farther in the future than next year | if not is_valid_year(year2) then return false; end -- no year farther in the future than next year | ||
Line 639: | Line 639: | ||
else | else | ||
return false; -- date format not one of the MOS:DATE approved formats | return false; -- date format not one of the MOS:DATE approved formats | ||
end | |||
if param ~= 'date' then -- CITEREF disambiguation only allowed in |date=; |year= & |publication-date= promote to date | |||
if anchor_year:match ('%l$') then | |||
return false; | |||
end | |||
end | end | ||
Line 1,102: | Line 1,108: | ||
xlate = is_xlateable (month); -- get translate <month>; returns translation or nil | xlate = is_xlateable (month); -- get translate <month>; returns translation or nil | ||
if xlate then | if xlate then | ||
date = mw.ustring.gsub (date, month, xlate); -- replace the English with the translation | date = mw.ustring.gsub (date, month, xlate); -- replace the English with the translation | ||
date_parameters_list[param_name].val = date; -- save the translated date | date_parameters_list[param_name].val = date; -- save the translated date |