UNPKG

calendar-date

Version:

Immutable object to represent a calendar date with zero dependencies

53 lines (52 loc) 2.01 kB
import { CalendarDate } from './CalendarDate'; type DateRangeExcludeOptions = { excludeStart?: boolean; excludeEnd?: boolean; }; export declare class CalendarDateRange { readonly start: CalendarDate; readonly end: CalendarDate; constructor(start: CalendarDate, end: CalendarDate, autoArrange?: boolean); equals(calendarDateRange: CalendarDateRange): boolean; toString(): string; toJSON(): string; /** * @param isoString pattern YYYY-MM-DD/YYYY-MM-DD */ static parse(isoString: string): CalendarDateRange; /** * Returns true if the given date ranges have gaps. * The date ranges will be sorted. */ static hasGaps(values: CalendarDateRange[], options?: DateRangeExcludeOptions): boolean; /** * Returns true if the given date ranges overlap. * The date ranges will be sorted. */ static hasOverlap(values: CalendarDateRange[], options?: DateRangeExcludeOptions): boolean; /** * Returns the total amount of days in included in this date range * including start and end day. */ getTotalDays(): number; /** * Returns the difference in days between the start and end date. * See documentation of CalendarDate.getDifferenceInDays for more information. */ getDifferenceInDays(): number; /** * Returns the difference in months as an integer, ignoring the day values. */ getDifferenceInMonths(): number; includes(calendarDate: CalendarDate, options?: DateRangeExcludeOptions): boolean; includes(calendarDateRange: CalendarDateRange, options?: DateRangeExcludeOptions): boolean; /** * Creates an iterator that yields each CalendarDate in the range from start to end (inclusive). */ iterateDatesInRange(options?: DateRangeExcludeOptions): IterableIterator<CalendarDate>; /** * Returns an array of all CalendarDate objects in the range. */ toDatesArrayInRange(options?: DateRangeExcludeOptions): CalendarDate[]; } export {};