UNPKG

datetoken

Version:

Parse relative datetime tokens into date objects

49 lines (43 loc) 1.12 kB
declare enum TokenType { END = "", ILLEGAL = "ILLEGAL", PLUS = "+", MINUS = "-", SLASH = "/", AT = "@", NUMBER = "NUMBER", MODIFIER = "MODIFIER", NOW = "NOW" } declare class Token$1 { type: TokenType; literal: string; constructor(tokenType: TokenType, tokenLiteral: string); } interface Expression { token: Token$1; operate(date?: Date): Date; toString(): string; toJSON(): object; } interface ClockI { getTime(): Date; } declare class Token { get at(): Date; set at(value: Date); get nodes(): Expression[]; get isSnapped(): boolean; get isModified(): boolean; static fromString(value: string, at?: Date, clock?: ClockI): Token; private readonly expressionNodes; private startAt?; private clock; constructor(nodes: Expression[], at?: Date, clock?: ClockI); toDate(): Date; toString(): string; toJSON(): object[]; } declare function tokenToDate(token: string, at?: Date, clock?: ClockI): Date; declare const datetoken: typeof tokenToDate; export { Token, datetoken, tokenToDate as default };