1 | import { ReferenceWithTimezone, ParsingComponents, ParsingResult } from "./results";
|
2 | import { Component, ParsedResult, ParsingOption, ParsingReference } from "./index";
|
3 | import { AsyncDebugBlock, DebugHandler } from "./debugging";
|
4 | export interface Configuration {
|
5 | parsers: Parser[];
|
6 | refiners: Refiner[];
|
7 | }
|
8 | export interface Parser {
|
9 | pattern(context: ParsingContext): RegExp;
|
10 | extract(context: ParsingContext, match: RegExpMatchArray): ParsingComponents | ParsingResult | {
|
11 | [c in Component]?: number;
|
12 | } | null;
|
13 | }
|
14 | export interface Refiner {
|
15 | refine: (context: ParsingContext, results: ParsingResult[]) => ParsingResult[];
|
16 | }
|
17 | export declare class Chrono {
|
18 | parsers: Array<Parser>;
|
19 | refiners: Array<Refiner>;
|
20 | constructor(configuration?: Configuration);
|
21 | clone(): Chrono;
|
22 | parseDate(text: string, referenceDate?: ParsingReference | Date, option?: ParsingOption): Date | null;
|
23 | parse(text: string, referenceDate?: ParsingReference | Date, option?: ParsingOption): ParsedResult[];
|
24 | private static executeParser;
|
25 | }
|
26 | export declare class ParsingContext implements DebugHandler {
|
27 | readonly text: string;
|
28 | readonly option: ParsingOption;
|
29 | readonly reference: ReferenceWithTimezone;
|
30 | readonly refDate: Date;
|
31 | constructor(text: string, refDate?: ParsingReference | Date, option?: ParsingOption);
|
32 | createParsingComponents(components?: {
|
33 | [c in Component]?: number;
|
34 | } | ParsingComponents): ParsingComponents;
|
35 | createParsingResult(index: number, textOrEndIndex: number | string, startComponents?: {
|
36 | [c in Component]?: number;
|
37 | } | ParsingComponents, endComponents?: {
|
38 | [c in Component]?: number;
|
39 | } | ParsingComponents): ParsingResult;
|
40 | debug(block: AsyncDebugBlock): void;
|
41 | }
|