Dates
in package
implements
NodeRule
Dates by the 7.0 grammar (specification section 2.6 and appendix A), uppercase:
- calendar escapes become calendar names: "@#DJULIAN@" → JULIAN, "@#DFRENCH R@" → FRENCH_R, "@#DROMAN@" and "@#DUNKNOWN@" → the extension calendars _ROMAN and _UNKNOWN, whose months become extension months (_ROMAN 24 _IUL 15);
- "B.C." → BCE;
- a dual year becomes the year it is by a 1 January new year (30 JAN 1648/49 → 30 JAN 1649, the appendix's example), a dual year whose second part is not the following year the first one, with the original value as PHRASE;
- "INT date (text)" → the date with PHRASE text (the whole value when the date had a dual year or the text has parentheses); "(text)" → no date, PHRASE text;
- a value that is not a 5.5.1 date is kept when it is a 7.0 one ("JULIAN 1650", written without the escape), otherwise it becomes PHRASE of an empty date.
Exact dates (CHAN.DATE, HEAD.DATE) have no PHRASE in 7.0: only their case changes. Days are not checked against the month: the source has KV3008 for that.
Table of Contents
Interfaces
- NodeRule
- A rule for one structure at a time. Rules that look at every line of a record are grouped in {@see Rule\Nodes}, which walks each record once for all of them.
Methods
- convert() : array{string, ?string}|null
- needsPrepass() : bool
- Whether the rule needs Context::prepass(): facts about the whole input before the first record.
- node() : bool
- Converts one structure (a record or a substructure; never a CONC/CONT line) with one of the rule's tags, as the structure is tagged when the walk reaches it, in place. Its substructures are visited after it, as they are when this returns.
- tags() : array<int, string>|null
Methods
convert()
public
convert(string $grammar, string $value) : array{string, ?string}|null
Parameters
- $grammar : string
-
DATE_VALUE, DATE_PERIOD or DATE_EXACT
- $value : string
Return values
array{string, ?string}|null —the 7.0 payload ('' for none) and PHRASE; null when nothing changes
needsPrepass()
Whether the rule needs Context::prepass(): facts about the whole input before the first record.
public
needsPrepass() : bool
Return values
boolnode()
Converts one structure (a record or a substructure; never a CONC/CONT line) with one of the rule's tags, as the structure is tagged when the walk reaches it, in place. Its substructures are visited after it, as they are when this returns.
public
node(Document $document, int $id, Context $context) : bool
Parameters
Return values
bool —false when the rule removed the structure: the rules after it and its substructures are skipped
tags()
public
tags() : array<int, string>|null
Return values
array<int, string>|null —the tags of the structures the rule converts; null for every structure