any-date-parser
Version:
Parse a wide range of date formats including human-input dates
34 lines (30 loc) • 856 B
TypeScript
// Generated by dts-bundle-generator v9.5.1
declare class MaybeValidDate extends Date {
invalid: string | null;
isValid(): boolean;
}
export type MatcherResult = Partial<{
year: number;
month: number;
day: number;
hour: number;
minute: number;
second: number;
millisecond: number;
offset: number;
invalid: string;
}>;
export declare function attempt(dateStr: string, locale?: string): MatcherResult;
export declare function fromObject(parsed: MatcherResult): MaybeValidDate;
export declare function fromString(dateStr: string, locale?: string): MaybeValidDate;
export declare function fromAny(any: string | number | Date, locale?: string): MaybeValidDate;
declare const parser: {
fromString: typeof fromString;
fromAny: typeof fromAny;
fromObject: typeof fromObject;
attempt: typeof attempt;
};
export {
parser as default,
};
export {};