אונטערשייד צווישן ווערסיעס פון "יחידה:Citation/CS1/Date validation"

קיין רעדאגירונג באמערקונג
(צופרידן?)
צייכן: צוריקגעשטעלט
אין תקציר עריכה
צייכן: צוריקגעשטעלט
שורה 15: שורה 15:


-- returns a number according to the sequence of seasons in a year: 1 for Winter, etc.  Capitalization and spelling must be correct. If not a valid season, returns 0
-- returns a number according to the sequence of seasons in a year: 1 for Winter, etc.  Capitalization and spelling must be correct. If not a valid season, returns 0
function get_season_number (season)
local function get_season_number (season)
local season_list = {['Winter']=1, ['Spring']=2, ['Summer']=3, ['Fall']=4, ['Autumn']=4, ['ווינטער']=1,['פרילינג']=2,['זומער']=3,['הארבסט']=4 }
local season_list = {['Winter']=1, ['Spring']=2, ['Summer']=3, ['Fall']=4, ['Autumn']=4, ['ווינטער']=1,['פרילינג']=2,['זומער']=3,['הארבסט']=4 }
local temp;
local temp;
שורה 24: שורה 24:


--returns true if month or season is valid (properly spelled, capitalized, abbreviated)
--returns true if month or season is valid (properly spelled, capitalized, abbreviated)
function is_valid_month_or_season (month_season)
local function is_valid_month_or_season (month_season)
if 0 == get_month_number (month_season) then -- if month text isn't one of the twelve months, might be a season
if 0 == get_month_number (month_season) then -- if month text isn't one of the twelve months, might be a season
if 0 == get_season_number (month_season) then -- not a month, is it a season?
if 0 == get_season_number (month_season) then -- not a month, is it a season?
שורה 40: שורה 40:
]]
]]


function is_valid_year(year)
local function is_valid_year(year)
if not is_set(year_limit) then
if not is_set(year_limit) then
year_limit = tonumber(os.date("%Y"))+1; -- global variable so we only have to fetch it once
year_limit = tonumber(os.date("%Y"))+1; -- global variable so we only have to fetch it once
שורה 53: שורה 53:
Where the two calendars overlap (1582 to approximately 1923) dates are assumed to be Gregorian.
Where the two calendars overlap (1582 to approximately 1923) dates are assumed to be Gregorian.
]]
]]
function is_valid_date (year, month, day)
local function is_valid_date (year, month, day)
local days_in_month = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
local days_in_month = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
local month_length;
local month_length;
שורה 89: שורה 89:
]]
]]


function is_valid_month_season_range(range_start, range_end)
local function is_valid_month_season_range(range_start, range_end)
local range_start_number = get_month_number (range_start);
local range_start_number = get_month_number (range_start);
שורה 131: שורה 131:
COinS_date is date_string without anchor_year disambiguator if any
COinS_date is date_string without anchor_year disambiguator if any
]]
]]
function check_date (date_string)
local function check_date (date_string)
local year; -- assume that year2, months, and days are not used;
local year; -- assume that year2, months, and days are not used;
local year2=0; -- second year in a year range
local year2=0; -- second year in a year range