date-fns
Version:
Modern JavaScript date utility library
37 lines (30 loc) • 839 B
JavaScript
exports.MinuteParser = void 0;
var _constants = require("../constants.cjs");
var _Parser = require("../Parser.cjs");
var _utils = require("../utils.cjs");
class MinuteParser extends _Parser.Parser {
priority = 60;
parse(dateString, token, match) {
switch (token) {
case "m":
return (0, _utils.parseNumericPattern)(
_constants.numericPatterns.minute,
dateString,
);
case "mo":
return match.ordinalNumber(dateString, { unit: "minute" });
default:
return (0, _utils.parseNDigits)(token.length, dateString);
}
}
validate(_date, value) {
return value >= 0 && value <= 59;
}
set(date, _flags, value) {
date.setMinutes(value, 0, 0);
return date;
}
incompatibleTokens = ["t", "T"];
}
exports.MinuteParser = MinuteParser;
;