Module:Citation/CS1/Date validation: Difference between revisions
Jump to navigation
Jump to search
m
Module:Citation/CS1/Date validation (edit)
Revision as of 15:05, 26 February 2019
, 26 February 2019Changed protection level for "Module:Citation/CS1/Date validation": to match the other modules in the suite ([Edit=Require administrator access] (indefinite) [Move=Require administrator access] (indefinite))
m (1 revision imported) |
m (Changed protection level for "Module:Citation/CS1/Date validation": to match the other modules in the suite ([Edit=Require administrator access] (indefinite) [Move=Require administrator access] (indefinite))) |
||
Line 376: | Line 376: | ||
if 12 < tonumber(month) or 1 > tonumber(month) or 1582 > tonumber(year) or 0 == tonumber(day) then return false; end -- month or day number not valid or not Gregorian calendar | if 12 < tonumber(month) or 1 > tonumber(month) or 1582 > tonumber(year) or 0 == tonumber(day) then return false; end -- month or day number not valid or not Gregorian calendar | ||
anchor_year = year; | anchor_year = year; | ||
elseif mw.ustring.match(date_string, "^%D- +[1-9]%d?, +[1-9]%d%d%d%a?$") then | elseif mw.ustring.match(date_string, "^%D- +[1-9]%d?, +[1-9]%d%d%d%a?$") then -- month-initial: month day, year | ||
month, day, anchor_year, year=mw.ustring.match(date_string, "(%D-) +(%d%d?),%s*((%d%d%d%d?)%a?)"); | month, day, anchor_year, year=mw.ustring.match(date_string, "(%D-) +(%d%d?),%s*((%d%d%d%d?)%a?)"); | ||
month = get_month_number (month); | month = get_month_number (month); | ||
if 0 == month then return false; end -- return false if month text isn't one of the twelve months | if 0 == month then return false; end -- return false if month text isn't one of the twelve months | ||
elseif mw.ustring.match(date_string, "^%D- +[1-9]%d?[%-–][1-9]%d?, +[1-9]%d%d%d%a?$") then | elseif mw.ustring.match(date_string, "^%D- +[1-9]%d?[%-–][1-9]%d?, +[1-9]%d%d%d%a?$") then -- month-initial day range: month day–day, year; days are separated by endash | ||
month, day, day2, anchor_year, year=mw.ustring.match(date_string, "(%D-) +(%d%d?)[%-–](%d%d?), +((%d%d%d%d)%a?)"); | month, day, day2, anchor_year, year=mw.ustring.match(date_string, "(%D-) +(%d%d?)[%-–](%d%d?), +((%d%d%d%d)%a?)"); | ||
if tonumber(day) >= tonumber(day2) then return false; end -- date range order is left to right: earlier to later; dates may not be the same; | if tonumber(day) >= tonumber(day2) then return false; end -- date range order is left to right: earlier to later; dates may not be the same; | ||
Line 389: | Line 389: | ||
year2=year; | year2=year; | ||
elseif mw.ustring.match(date_string, "^[1-9]%d? +%D- +[1-9]%d%d%d%a?$") then | elseif mw.ustring.match(date_string, "^[1-9]%d? +%D- +[1-9]%d%d%d%a?$") then -- day-initial: day month year | ||
day, month, anchor_year, year=mw.ustring.match(date_string, "(%d%d*)%s*(%D-) +((%d%d%d%d?)%a?)"); | day, month, anchor_year, year=mw.ustring.match(date_string, "(%d%d*)%s*(%D-) +((%d%d%d%d?)%a?)"); | ||
month = get_month_number (month); | month = get_month_number (month); | ||
if 0 == month then return false; end -- return false if month text isn't one of the twelve months | if 0 == month then return false; end -- return false if month text isn't one of the twelve months | ||
elseif mw.ustring.match(date_string, "^[1-9]%d?[%-–][1-9]%d? +%D- +[1-9]%d%d%d%a?$") then | --[[ NOT supported at en.wiki | ||
elseif mw.ustring.match(date_string, "^[1-9]%d%d%d%a? +%D- +%d%d?$") then -- year-initial: year month day; day: 1 or 2 two digits, leading zero allowed | |||
anchor_year, year, month, day=mw.ustring.match(date_string, "((%d%d%d%d?)%a?) +(%D-) +(%d%d?)"); | |||
month = get_month_number (month); | |||
if 0 == month then return false; end -- return false if month text isn't one of the twelve months | |||
-- end NOT supported at en.wiki ]] | |||
elseif mw.ustring.match(date_string, "^[1-9]%d?[%-–][1-9]%d? +%D- +[1-9]%d%d%d%a?$") then -- day-range-initial: day–day month year; days are separated by endash | |||
day, day2, month, anchor_year, year=mw.ustring.match(date_string, "(%d%d?)[%-–](%d%d?) +(%D-) +((%d%d%d%d)%a?)"); | day, day2, month, anchor_year, year=mw.ustring.match(date_string, "(%d%d?)[%-–](%d%d?) +(%D-) +((%d%d%d%d)%a?)"); | ||
if tonumber(day) >= tonumber(day2) then return false; end -- date range order is left to right: earlier to later; dates may not be the same; | if tonumber(day) >= tonumber(day2) then return false; end -- date range order is left to right: earlier to later; dates may not be the same; |