"మాడ్యూల్:Citation/CS1/Date validation" కూర్పుల మధ్య తేడాలు

Synch from sandbox;
(Synch from sandbox;)
(Synch from sandbox;)
adding 24 hours gives 2015-01-03T00:00:00 – one second more than tomorrow
 
This function does not work if it is fed month names for languages other than English. Wikimedia #time: parser apparently doesn't understand
apparently doesn't understand non-Engish date month names. This function will always return false when the date contains a non-English month name
contains a non-English month name because good1 is false after the call to lang.formatDate(). To get around that
For the time being, to usecall this function, supply it with YYYY-MM-DD format dates. See
 
For the time being, to use this function, supply it with YYYY-MM-DD format dates. See
[[bs:Modul:Citation/CS1/Date validation/igralište]] for one possible solution.
 
]=]
return false; -- one or both failed to convert to unix time stamp
end
 
if 979516800 <= access_ts and access_ts < tomorrow_ts then -- Wikipedia start date <= accessdate < tomorrow's date
return true;
]]
 
local function check_date (date_string, tCOinS_date, test_accessdate)
local year; -- assume that year2, months, and days are not used;
local year2=0; -- second year in a year range
month = get_season_number (month); -- for metadata
 
elseif mw.ustring.match(date_string, "^%a+ +[1-9]%d%d%d% +[%-–] +%a+ +[1-9]%d%d%d%a?$") then -- month/season year - month/season year; separated by spaced endash
month, year, month2, anchor_year, year2=mw.ustring.match(date_string, "(%a+) +(%d%d%d%d) +[%-–] +(%a+) +((%d%d%d%d)%a?)");
anchor_year=year..'–'..anchor_year; -- assemble anchor_year from both years
if tonumber(year) >= tonumber(year2) then return false; end -- left to right, earlier to later, not the same
else
return false; -- date format not one of the MOS:DATE approved formats
end
 
if test_accessdate then -- test accessdate here because we have numerical date parts
if 0 ~= year and 0 ~= month and 0 ~= day and -- all parts of a single date required
0 == year2 and 0 == month2 and 0 == day2 then -- none of these; accessdate must not be a range
if not is_valid_accessdate (year..'-'..month..'-'..day) then
return false; -- return false when accessdate out of bounds
end
else
return false; -- return false when accessdate is a range of two dates
end
end
 
end
elseif 'date'==k then -- if the parameter is |date=
if v:match("^n%.d%.%a?$") then -- if |date=n.d. with or without a CITEREF disambiguator
good_date, anchor_year, COinS_date = true, v:match("((n%.d%.)%a?)"); --"n.d."; no error when date parameter is set to no date
elseif v:match("^nd%a?$") then -- if |date=nd with or without a CITEREF disambiguator
good_date, anchor_year, COinS_date = check_date (v, tCOinS_date); -- go test the date
end
elseif 'access-dateyear'==k then -- if the parameter is |access-dateyear= it should hold only a year value
if v:match("^[1-9]%d%d%d?%a?$") then -- if |year= 3 or 4 digits only with or without a CITEREF disambiguator
good_date = check_date (v); -- go test the date
if true == good_date, then --anchor_year, ifCOinS_date the= date istrue, v:match("((%d+)%a valid date?)");
good_date = is_valid_accessdate (v); -- is Wikipedia start date < accessdate < tomorrow's date?
end
elseif 'access-date'==k then -- if the parameter is |date=
good_date = check_date (v, nil, true); -- go test the date; nil is a placeholder; true is the test_accessdate flag
elseif 'embargo'==k then -- if the parameter is |embargo=
good_date = check_date (v); -- go test the date
format_str = long_formats[format];
end
-- convert date and save;
date_parameters_list[param_name] = mw.text.trim (os.date (format_str, os.time(source_date))); -- convertstrip dateleading space when single digit day and save%e is first format
end
end
"https://te.wikipedia.org/wiki/ప్రత్యేక:MobileDiff/1993329" నుండి వెలికితీశారు