UNPKG

date-shortcut-parser

Version:

A lightweight and powerful TypeScript library for parsing human-readable date shortcuts into `Date` objects.

35 lines 867 B
//#region src/index.d.ts interface DatePattern { regex: RegExp; format: string; } interface Localization { year: string[]; month: 'long' | 'short' | 'numeric' | string[]; week: string[]; day: string[]; today: string[]; weekday: string[]; datePatterns: DatePattern[]; am?: string[]; pm?: string[]; } interface DateShortcutParserOptions { fromDate?: Date; locale?: 'en' | 'de' | 'fr' | 'tr' | Localization; defaultTime?: string; } declare class DateShortcutParser { private options; private locale; private defaultTime; constructor(options?: DateShortcutParserOptions); private resolveLocale; private _parseTime; parse(shortcut: string): Date; private getOrdinalSuffix; private findNthWeekday; private findClosestWorkday; } //#endregion export { DatePattern, DateShortcutParser, DateShortcutParserOptions, Localization };