Module:Citation/CS1/Date validation: Difference between revisions
No edit summary |
No edit summary Tag: Manual revert |
||
| Line 700: | Line 700: | ||
v.val = mw.ustring.gsub(v.val, '%d', cfg.date_names.local_digits); -- translate 'local' digits to Western 0-9 | v.val = mw.ustring.gsub(v.val, '%d', cfg.date_names.local_digits); -- translate 'local' digits to Western 0-9 | ||
if v.val:match("^c%. [1-9]%d%d%d?%a?$") then -- special case for c. year or with or without CITEREF disambiguator - only |date= and |year= | if v.val:match("^c%. [1-9]%d%d%d?%a?$") then -- special case for c. year or with or without CITEREF disambiguator - only |date= and |year= | ||
local year = v.val:match("c%. ([1-9]%d%d%d?)%a?"); -- get the year portion so it can be tested | |||
if 'date' == k then | |||
anchor_year, COinS_date = v.val:match("((c%. [1-9]%d%d%d?)%a?)"); -- anchor year and COinS_date only from |date= parameter | |||
good_date = is_valid_year(year); | |||
elseif 'year' == k then | |||
good_date = is_valid_year(year); | |||
end | |||
elseif 'date' == k then -- if the parameter is |date= | elseif 'date' == k then -- if the parameter is |date= | ||
if v.val:match("^n%.d%.%a?$") then -- ToDo: I18N -- if |date=n.d. with or without a CITEREF disambiguator | if v.val:match("^n%.d%.%a?$") then -- ToDo: I18N -- if |date=n.d. with or without a CITEREF disambiguator | ||
| Line 1,155: | Line 1,155: | ||
]] | ]] | ||
local function set_selected_modules (cfg_table_ptr, utilities_page_ptr) | |||
add_prop_cat = utilities_page_ptr.add_prop_cat ; -- import functions from selected Module:Citation/CS1/Utilities module | |||
is_set = utilities_page_ptr.is_set; | |||
in_array = utilities_page_ptr.in_array; | |||
set_message = utilities_page_ptr.set_message; | |||
substitute = utilities_page_ptr.substitute; | |||
wrap_style = utilities_page_ptr.wrap_style; | |||
cfg = cfg_table_ptr; -- import tables from selected Module:Citation/CS1/Configuration | |||
end | |||
| Line 1,166: | Line 1,177: | ||
date_hyphen_to_dash = date_hyphen_to_dash, | date_hyphen_to_dash = date_hyphen_to_dash, | ||
date_name_xlate = date_name_xlate, | date_name_xlate = date_name_xlate, | ||
set_selected_modules = set_selected_modules | set_selected_modules = set_selected_modules | ||
} | } | ||