/** @import { Level2Component, Level2ComponentSpec } from "../component/Level2Component.mjs" */ /** @import { CalendarUnit } from "../../calendar/unit/CalendarUnit.mjs" */ /** * @typedef {Object} Level0DurationParseResult * @property {number} [seconds] * @property {number} [minutes] * @property {number} [hours] * @property {number} [days] * @property {number} [months] * @property {number} [years] */ /** * Parses duration strings in the ISO-8601/EDTF "PxxHyyMzzS" format, * with support for component-level fuzziness ("P~150S") and whole-duration fuzziness ("~P150S"). */ export class Level2DurationParser extends Level2ComponentParser { /** * @readonly * @type {string} */ static readonly yearsGroup: string; /** * @readonly * @type {string} */ static readonly monthsGroup: string; /** * The months of an ISO 8601 duration ("P1Y2M3DT4H"), designated by a single "M" (the "MM" designator being the legacy one). * * @readonly * @type {string} */ static readonly isoMonthsGroup: string; /** * @readonly * @type {string} */ static readonly daysGroup: string; /** * @readonly * @type {string} */ static readonly hoursGroup: string; /** * @readonly * @type {string} */ static readonly minutesGroup: string; /** * @readonly * @type {string} */ static readonly secondsGroup: string; /** * @readonly * @type {string} */ static readonly durationGroup: string; /** * The group of the qualifier that follows the whole duration ("P10M~"), which qualifies everything to its left. * * @readonly * @type {string} */ static readonly suffixGroup: string; /** * Parses the quantity of each unit, which can have more digits than a date component ("P150S", "P26300H"). * * @readonly * @type {Level2DurationComponentParser} */ static readonly componentParser: Level2DurationComponentParser; /** * @param {string} prefix Prefix for group names, if any. * @param {string} group The name of the group matching the quantity and its designator ("years"...). * @param {string} component The name of the date component whose format is reused for the quantity ("year"...). * @param {string} designator The unit designator that follows the quantity ("Y", "MM"...). * @param {string} [lookahead] A lookahead assertion to check after the designator. * @return {string} The pattern matching a duration component, capturing its quantity in a group of its own (see {@link Level2DurationParser.quantityGroup}). */ static componentFormat(prefix: string, group: string, component: string, designator: string, lookahead?: string): string; /** * @param {string} group The name of a component group ("years"...). * @return {string} The name of the group that only contains the quantity, without the unit designator. */ static quantityGroup(group: string): string; /** * A "M" is minutes, unless it comes before the "T" that introduces the time part (ISO 8601: "P1Y2M3DT4H"), where it is months. * "MM" is always months, which disambiguates ("P2MM"). A "M" followed by days ("P2M3D") cannot be minutes either, so it is months too. * * @type {string} */ static isoMonthsLookahead: string; /** * @param {string} prefix * @return {string} */ static format(prefix?: string): string; /** * @template {Level2Component} C * @param {string} str The quantity of a duration unit, possibly qualified ("150", "~150"). * @param {new (spec: Level2ComponentSpec, unit: CalendarUnit) => C} Component The component class to create. * @param {CalendarUnit} unit The duration unit. * @return {C} */ static parseComponent(str: string, Component: new (spec: Level2ComponentSpec, unit: CalendarUnit) => C, unit: CalendarUnit): C; constructor(); } export type Level0DurationParseResult = { seconds?: number; minutes?: number; hours?: number; days?: number; months?: number; years?: number; }; import { Level2ComponentParser } from "../component/Level2ComponentParser.mjs"; import { Level2DurationComponentParser } from "./Level2DurationComponentParser.mjs"; import type { Level2Component } from "../component/Level2Component.mjs"; import type { Level2ComponentSpec } from "../component/Level2Component.mjs"; import type { CalendarUnit } from "../../calendar/unit/CalendarUnit.mjs"; //# sourceMappingURL=Level2DurationParser.d.mts.map