మాడ్యూల్:Citation/CS1/Date validation: కూర్పుల మధ్య తేడాలు
Content deleted Content added
చి en:Module:Citation/CS1/Date_validation నుండి కూర్పులను దిగుమతి చేసాం |
Arjunaraoc (చర్చ | రచనలు) Reverted to revision 2721725 by Arjunaraoc: to fix check date error flagging. (TW) ట్యాగు: రద్దుచెయ్యి |
||
పంక్తి 5:
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
Line 37 ⟶ 27:
local function is_valid_accessdate (accessdate)
local lang = mw.getContentLanguage();
local good1, good2;
local access_ts, tomorrow_ts; -- to hold unix time stamps representing the dates
good1, access_ts = pcall
good2, tomorrow_ts = pcall
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
tomorrow_ts = tonumber (tomorrow_ts) or
else
return false; -- one or both failed to convert to unix time stamp
Line 147 ⟶ 138:
]]
local year_limit;
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
return tonumber(year) <= year_limit; -- false if year is in the future more than one year
end
Line 573 ⟶ 562:
if not is_valid_year(year2) then return false; end -- no year farther in the future than next year
elseif
anchor_year, year=
if false == is_valid_year(year) then
return false;
Line 1,019 ⟶ 1,008:
if mode then -- might be a season
xlate =
date = mw.ustring.gsub (date, month, xlate); -- replace the English with the translation
date_parameters_list[param_name].val = date; -- save the translated date
|