Changes
lua script error fix for non-Latin digits in |year=;
local is_set, in_array; -- imported functions from selected Module:Citation/CS1/Utilities
local cfg; -- table of tables imported from selected Module:Citation/CS1/Configuration
--[[--------------------------< F I L E - S C O P E D E C L A R A T I O N S >--------------------------------
File-scope variables are declared here
]]
local lang_object = mw.getContentLanguage(); -- used by is_valid_accessdate(), is_valid_year(), date_name_xlate(); TODO: move to ~/Configuration?
local year_limit; -- used by is_valid_year()
local function is_valid_accessdate (accessdate)
local good1, good2;
local access_ts, tomorrow_ts; -- to hold unix time stamps representing the dates
if good1 and good2 then -- lang.formatDate() returns a timestamp in the local script which which tonumber() may not understand
access_ts = tonumber (access_ts) or langlang_object:parseFormattedNumber (access_ts); -- convert to numbers for the comparison; tomorrow_ts = tonumber (tomorrow_ts) or langlang_object:parseFormattedNumber (tomorrow_ts);
else
return false; -- one or both failed to convert to unix time stamp
]]
local function is_valid_year(year)
if not is_set(year_limit) then
year_limit = tonumber(os.date("%Y"))+1; -- global variable so we only have to fetch it once
end
end
if not is_valid_year(year2) then return false; end -- no year farther in the future than next year
elseif date_string:mw.ustring.match (date_string, patterns['y'][1]) then -- year; here accept either YYY or YYYY anchor_year, year=date_string:mw.ustring.match (date_string, patterns['y'][1]);
if false == is_valid_year(year) then
return false;
if mode then -- might be a season
xlate = mw.getContentLanguage()lang_object:formatDate(mode, '1' .. month); -- translate the month name to this local language
date = mw.ustring.gsub (date, month, xlate); -- replace the English with the translation
date_parameters_list[param_name].val = date; -- save the translated date