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

Content deleted Content added
Synch from sandbox;
Synch from sandbox;
పంక్తి 9:
 
 
--[=[--------------------------< I S _ V A L I D _ A C C E S S D A T E >----------------------------------------
 
returns true if:
పంక్తి 21:
adding 24 hours gives 2015-01-03T00:00:00 – one second more than tomorrow
 
This function does not work for languages other than English. Wikimedia #time: parser apparently doesn't understand
]]
non-Engish date month names. This function will always return false when the date contains a non-English month name
because good1 is false after the call to lang.formatDate.
 
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.
 
]=]
 
local function is_valid_accessdate (accessdate)
Line 54 ⟶ 61:
local long_months = {['January']=1, ['February']=2, ['March']=3, ['April']=4, ['May']=5, ['June']=6, ['July']=7, ['August']=8, ['September']=9, ['October']=10, ['November']=11, ['December']=12};
local short_months = {['Jan']=1, ['Feb']=2, ['Mar']=3, ['Apr']=4, ['May']=5, ['Jun']=6, ['Jul']=7, ['Aug']=8, ['Sep']=9, ['Oct']=10, ['Nov']=11, ['Dec']=12};
if temp then return temp;long_months[month] endor -- if month is the long-form name
local temp;
if short_months[month] temp then return temp; endor -- if month is the short-form name
temp=long_months[month];
return 0; -- misspelled, improper case, or not a month name
if temp then return temp; end -- if month is the long-form name
temp=short_months[month];
if temp then return temp; end -- if month is the short-form name
return 0; -- misspelled, improper case, or not a month name
end
 
Line 195 ⟶ 199:
local function is_valid_month_season_range(range_start, range_end)
local range_start_number = get_month_number (range_start);
local range_end_number;
if 0 == range_start_number then -- is this a month range?
local range_start_number = get_season_number (range_start); -- not a month; is it a season? get start season number
local range_end_number = get_season_number (range_end); -- get end season number
 
if 0 ~= range_start_number then -- is start of range a season?
Line 211 ⟶ 216:
end
 
local range_end_number = get_month_number (range_end); -- get end month number
if range_start_number < range_end_number then -- range_start is a month; does range_start precede range_end?
if is_valid_month_range_style (range_start, range_end) then -- do months have the same style?