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

en>Trappist the monk
No edit summary
 
Viceroy Sam (talk | contribs)
m →top: Typo fixing, typos fixed: etc → etc. (2), october → October, hemispere → hemisphere, 21-41 → 21–41 (2)
 
(One intermediate revision by one other user not shown)
Line 106: Line 106:
Season numbering is defined by Extended Date/Time Format (EDTF) Specification (https://www.loc.gov/standards/datetime/)
Season numbering is defined by Extended Date/Time Format (EDTF) Specification (https://www.loc.gov/standards/datetime/)
which became part of ISO 8601 in 2019.  See '§Sub-year groupings'.  The standard defines various divisions using
which became part of ISO 8601 in 2019.  See '§Sub-year groupings'.  The standard defines various divisions using
numbers 21-41.  cs1|2 only supports generic seasons.  EDTF does support the distinction between north and south
numbers 21–41.  cs1|2 only supports generic seasons.  EDTF does support the distinction between north and south
hemispere seasons but cs1|2 has no way to make that distinction.
hemisphere seasons but cs1|2 has no way to make that distinction.


These additional divisions not currently supported:
These additional divisions not currently supported:
Line 138: Line 138:
Quarter numbering is defined by Extended Date/Time Format (EDTF) Specification (https://www.loc.gov/standards/datetime/)
Quarter numbering is defined by Extended Date/Time Format (EDTF) Specification (https://www.loc.gov/standards/datetime/)
which became part of ISO 8601 in 2019.  See '§Sub-year groupings'.  The standard defines various divisions using
which became part of ISO 8601 in 2019.  See '§Sub-year groupings'.  The standard defines various divisions using
numbers 21-41.  cs1|2 only supports generic seasons and quarters.
numbers 21–41.  cs1|2 only supports generic seasons and quarters.


These additional divisions not currently supported:
These additional divisions not currently supported:
Line 332: Line 332:
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 350: Line 349:
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 450: Line 449:
-- month/season range year; months separated by endash
-- month/season range year; months separated by endash
['M-My'] = {'^(%D-)[%-–](%D-) +((%d%d%d%d)%a?)$', 'm', 'm2', 'a', 'y'},
['M-My'] = {'^(%D-)[%-–](%D-) +((%d%d%d%d)%a?)$', 'm', 'm2', 'a', 'y'},
-- month/season year or proper-name year; quarter year when First Quarter YYYY etc
-- month/season year or proper-name year; quarter year when First Quarter YYYY etc.
['My'] = {'^([^%d–]-) +((%d%d%d%d)%a?)$', 'm', 'a', 'y'}, -- this way because endash is a member of %D; %D- will match January–March 2019 when it shouldn't
['My'] = {'^([^%d–]-) +((%d%d%d%d)%a?)$', 'm', 'a', 'y'}, -- this way because endash is a member of %D; %D- will match January–March 2019 when it shouldn't


Line 817: Line 816:
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