Difference between revisions of Module:Citation/CS1/Date validation

NottNott (talk | contribs)
m 1 revision imported
Viceroy Sam (talk | contribs)
m top: Typo fixing, typos fixed, etc → etc., october → October
 
Line 277: Line 277:
year, year2 – always present; if before 1582, ignore months and days if present
year, year2 – always present; if before 1582, ignore months and days if present
month, month2 – 0 if not provided, 1-12 for months, 21-24 for seasons; 99 Christmas
month, month2 – 0 if not provided, 1-12 for months, 21-24 for seasons; 99 Christmas
day, day2 –  0 if not provided, 1-31 for days
the output table receives:
the output table receives:
Line 294: Line 293:
local day = tonumber (input.day);
local day = tonumber (input.day);
if (0 ~= day) and -- day must have a value for this to be a whole date
if (0 ~= day) and -- day must have a value for this to be a whole date
(((1582 == year) and (10 <= month) and (12 >= month)) or -- any whole 1582 date from 1 october to 31 December or
(((1582 == year) and (10 <= month) and (12 >= month)) or -- any whole 1582 date from 1 October to 31 December or
((1926 == year) and (1 == month) and (1 == input.day)) or -- 1 January 1926 or
((1926 == year) and (1 == month) and (1 == input.day)) or -- 1 January 1926 or
((1582 < year) and (1925 >= year))) then -- any date 1 January 1583 – 31 December 1925
((1582 < year) and (1925 >= year))) then -- any date 1 January 1583 – 31 December 1925
Line 751: Line 750:
patterns['ymd'][1] is the match pattern with captures for mw.ustring.match()
patterns['ymd'][1] is the match pattern with captures for mw.ustring.match()
patterns['ymd'][2] is an indicator letter identifying the content of the first capture
patterns['ymd'][2] is an indicator letter identifying the content of the first capture
patterns['ymd'][3] ... the second capture etc
patterns['ymd'][3] ... the second capture etc.


when a pattern matches a date, the captures are loaded into table t{} in capture order using the idemtifier
when a pattern matches a date, the captures are loaded into table t{} in capture order using the idemtifier