/** * Date segment */ type Segment = { /** * Year, e.g. 2020, 30, -2 */ year: number; /** * Month, e.g. 0, 1, 11 */ month: number; /** * Day of the month, e.g. 1, 28, 31 */ day: number; }; /** * Date format: * - yyyy-MM-dd (e.g. 2020-06-30, 0030-04-30, -0002-12-31) * - yyyy-MM (e.g. 2020-06, 0030-04, -0002-12) * - yyyy (e.g. 2020, 0030, -0002) */ declare enum Format { yyyy = "yyyy", yyyyMM = "yyyy-MM", yyyyMMdd = "yyyy-MM-dd" } type InputFormat = Format | keyof typeof Format; /** * Get Local/UTC values segments of Date object or value string * @param value Valid date or a string in a format 2019, 2019-12 or 2019-12-31 * @param [isUTC=false] True to get UTC values, false to get Local values * @returns Segment */ declare const toSegment: (value: string | Date, isUTC?: boolean) => Segment; /** * Format Date or Segment to Local Date string. * @param value A valid Date or Segment * @param [format='yyyy-MM-dd'] Date format, one of 'yyyy-MM-dd' | 'yyyy-MM' | 'yyyy' * @returns A formatted date */ declare const format: (value: Segment | Date, format?: InputFormat) => string; /** * Format Date or Segment to UTC Date string. * @param value A valid Date or Segment * @param [format='yyyy-MM-dd'] Date format, one of 'yyyy-MM-dd' | 'yyyy-MM' | 'yyyy' * @returns A formatted date */ declare const utcFormat: (value: Segment | Date, format?: InputFormat) => string; /** * Try to guess date format * @param value Value to test * @returns format Date format */ declare const getFormat: (value: string) => Format | null; /** * Return true if value confirms ta a passed format * @param value Value to check * @param [format] The format to validate value against. If not defined, try to guess the format * @returns true if value format is correct */ declare const isValid: (value: string, format?: InputFormat | null) => boolean; /** * Get Local Date object from value string or Segment. * @param value Value to parse, Segment or 'yyyy-MM-dd' | 'yyyy-MM' | 'yyyy' * @returns parsed date or invalid date */ declare const parse: (value: string | Segment) => Date; /** * Get UTC Date object from value string or Segment. * @param value Value to parse, Segment or 'yyyy-MM-dd' | 'yyyy-MM' | 'yyyy' * @returns parsed date or invalid date */ declare const utcParse: (value: string | Segment) => Date; /** * Get number of day in a month * @param year A year to check * @param month A month to check * @returns the number of days in month */ declare const getDaysInMonth: (year: number, month: number) => number; export { Segment, Format, InputFormat, toSegment, getFormat, format, utcFormat, parse, utcParse, isValid, getDaysInMonth };