23 lines
530 B
JavaScript
23 lines
530 B
JavaScript
|
import { Parser } from "../Parser.mjs";
|
||
|
import { parseNDigitsSigned } from "../utils.mjs";
|
||
|
|
||
|
export class ExtendedYearParser extends Parser {
|
||
|
priority = 130;
|
||
|
|
||
|
parse(dateString, token) {
|
||
|
if (token === "u") {
|
||
|
return parseNDigitsSigned(4, dateString);
|
||
|
}
|
||
|
|
||
|
return parseNDigitsSigned(token.length, dateString);
|
||
|
}
|
||
|
|
||
|
set(date, _flags, value) {
|
||
|
date.setFullYear(value, 0, 1);
|
||
|
date.setHours(0, 0, 0, 0);
|
||
|
return date;
|
||
|
}
|
||
|
|
||
|
incompatibleTokens = ["G", "y", "Y", "R", "w", "I", "i", "e", "c", "t", "T"];
|
||
|
}
|