/** * A list of shared functions across date, datetime and time */ import { Segment as DateSegment, InputFormat as InputDateFormat } from './date.js'; import { Segment as DateTimeSegment, InputFormat as InputDateTimeFormat } from './datetime.js'; import { InputFormat as InputTimeFormat, Segment as TimeSegment } from './time.js'; type Format = InputTimeFormat | InputDateFormat | InputDateTimeFormat; type Unit = 'year' | 'month' | 'day' | 'hour' | 'minute' | 'second' | 'millisecond'; type Segment = DateTimeSegment | (TimeSegment & { year?: number; month?: number; day?: number; }) | (DateSegment & { hours?: number; minutes?: number; seconds?: number; milliseconds?: number; }); /** * Parse value into segment * @param value A valid Date or Segment * @param isUTC Local or UTC * @returns segment Date segment */ declare const toSegment: (value: string | Date, isUTC?: boolean) => Segment; /** * Format Date or Segment to Local formatted string. * @param value A valid Date or Segment * @param [format='yyyy-MM-dd'T'HH:mm'] format * @returns A formatted string */ declare const format: (value: Segment | Date, format?: Format) => string; /** * Format Date or Segment to UTC formatted string. * @param value A valid Date or Segment * @param [format='yyyy-MM-dd'T'HH:mm'] format * @returns A formatted string */ declare const utcFormat: (value: Segment | Date, format?: Format) => string; /** * Get Local Date object from value string or Segment. * @param value Value to parse or Segment * @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 or Segment * @returns parsed Date or Invalid Date */ declare const utcParse: (value: string | Segment) => Date; /** * Try to guess value format * @param value Value to test * @returns format Format */ declare const getFormat: (value: string) => Format | null; /** * Is the first date after the second one? * @param value the date that should be after the other one to return true * @param compare the date to compare with * @returns the first date is after the second date */ declare const isAfter: (value: string, compare: string) => boolean; /** * Is the first date before the second one? * @param value the date that should be before the other one to return true * @param compare the date to compare with * @returns the first date is before the second date */ declare const isBefore: (value: string, compare: string) => boolean; /** * Are the given dates in the same day? * @param value the first date to check * @param compare the second date to check * @returns the dates are in the same day */ declare const isSameDay: (value: string, compare: string) => boolean; /** * Are the given dates in the same month? * @param value the first date to check * @param compare the second date to check * @returns the dates are in the same month */ declare const isSameMonth: (value: string, compare: string) => boolean; /** * Are the given dates in the same year? * @param value the first date to check * @param compare the second date to check * @returns the dates are in the same year */ declare const isSameYear: (value: string, compare: string) => boolean; /** * Is the given date today? * @param value the date to check * @returns the date is today */ declare const isToday: (value: string) => boolean; /** * Is the given date this month? * @param value the date to check * @returns the date is this month */ declare const isThisMonth: (value: string) => boolean; /** * Is the given date this year? * @param value the date to check * @returns the date is this year */ declare const isThisYear: (value: string) => boolean; /** * Does the given date fall on a weekend? * @param value the date to check * @returns the date falls on a weekend */ declare const isWeekend: (value: string) => boolean; /** * Add the specified number of units to the given date * @param value The date to be changed * @param unit The unit: `year`, `month`, `day`, `hour`, `minute`, `second` or `millisecond` * @param amount The amount of units to be added, e.g. 1 to increase or -1 to decrease * @returns date The new date */ declare const addUnit: (value: string, unit: Unit, amount: number) => string; /** * Add the specified number of months to the given date * @param value the date to be changed * @param amount the amount of months to be added * @returns the new date with the months added */ declare const addMonths: (value: string, amount: number) => string; /** * Subtract the specified number of months to the given date * @param value the date to be changed * @param amount the amount of months to be subtracted * @returns the new date with the months subtracted */ declare const subMonths: (value: string, amount: number) => string; /** * Returns `true` or `false` depending on whether the hours are before, or, after noon * @param value the time to check * @returns Result */ declare const isAM: (value: string) => boolean; /** * Returns opposite of isAM * @param value the time to check * @returns Result */ declare const isPM: (value: string) => boolean; /** * Add offset in milliseconds to the value * @param value the time * @param amount number of milliseconds to add * @returns new value */ declare const addOffset: (value: string, amount: number) => string; /** * Subtract offset in milliseconds from the value * @param value the time * @param amount number of milliseconds to subtract * @returns new value */ declare const subOffset: (value: string, amount: number) => string; /** * Cycles through the unit by a specified amount, not affecting any other part of the date * @param value The date to be changed * @param unit The unit: `year`, `month`, `day`, `hour`, `minute`, `second` or `millisecond` * @param amount The amount of units to be iterated, e.g. 1 to go up or -1 to go down * @returns date The new date */ declare const iterateUnit: (value: string, unit: Unit, amount: number) => string; export { Format, Unit, isAfter, isBefore, isAM, isPM, addOffset, subOffset, format, utcFormat, parse, utcParse, getFormat, isSameDay, isSameMonth, isSameYear, isToday, isThisMonth, isThisYear, addMonths, subMonths, isWeekend, addUnit, iterateUnit, toSegment };