import { Inclusivity, InclusivityString } from '../common/inclusivity.js'; import { PlainDate, PlainDateInput } from '../plain-date/plain-date.js'; import { PlainDateUnit } from '../plain-date/index.js'; import { DatePeriod } from '../common/date-period.enum.js'; import { Duration } from '@wisemen/quantity'; /** * DateRange only works with inclusive ranges internally, except for infinities * When an exclusive date is given, this date is mapped to the next or previous inclusive date * for the upper and lower bound respectively * * As a result, empty ranges cannot be represented. */ export declare class DateRange { readonly startDate: PlainDate; readonly endDate: PlainDate; constructor(startDate: PlainDateInput, endDate: PlainDateInput); constructor(startDate: PlainDateInput, endDate: PlainDateInput, inclusivity: Inclusivity); constructor(startDate: PlainDateInput, endDate: PlainDateInput, inclusivity: InclusivityString); constructor(startDate: PlainDateInput, endDate: PlainDateInput, lowerBoundInclusivity: Inclusivity, upperBoundInclusivity: Inclusivity); get years(): number; get months(): number; get quarters(): number; get weeks(): number; get days(): number; contains(date: PlainDateInput): boolean; startsAfter(date: PlainDateInput): boolean; startsAfterOrOn(date: PlainDateInput): boolean; startsBefore(date: PlainDateInput): boolean; startsBeforeOrOn(date: PlainDateInput): boolean; endsBefore(date: PlainDateInput): boolean; endsBeforeOrOn(date: PlainDateInput): boolean; endsAfter(date: PlainDateInput): boolean; endsAfterOrOn(date: PlainDateInput): boolean; getDatePeriod(on?: PlainDateInput): DatePeriod; overlaps(withRange: DateRange): boolean; overlap(withRange: DateRange): DateRange; diff(withRange: DateRange): DateRange[]; isSame(otherRange: DateRange): boolean; isFinite(): boolean; toString(): string; valueOf(): string; /** Returns a new date range instance with the new end date */ withEndDate(endDate: PlainDateInput): DateRange; /** Returns a new date range instance with the new start date */ withStartDate(startDate: PlainDateInput): DateRange; /** Returns true if this range ends before the other range starts */ isStrictlyBefore(other: DateRange): boolean; /** * Returns a new date range with both boundaries expanded \ * - start date = this.startDate.subtractDuration(duration) * - end date = this.endDate.addDuration(duration) */ expand(duration: Duration): DateRange; /** * Returns a new date range with both boundaries expanded \ * - start date = this.startDate.subtractDuration(lower) * - end date = this.endDate.addDuration(upper) */ expand(lower: Duration, upper: Duration): DateRange; /** Returns true if this range starts after the other range ends */ isStrictlyAfter(other: DateRange): boolean; precedes(other: DateRange): boolean; isPrecededBy(other: DateRange): boolean; succeeds(other: DateRange): boolean; isSucceededBy(other: DateRange): boolean; isAdjacentTo(other: DateRange): boolean; merge(withOther: DateRange): DateRange; /** * Compares the order of the given date range with this date range. \ * Ranges are compared first by their start date, then by their end date. \ * returns < 0 if this range starts before the other (or starts at the same time but ends before) \ * returns 0 if both ranges have the same start and end dates \ * returns > 0 if this range starts after the other (or starts at the same time but ends after) \ * \ * This method is useful for sorting arrays of date ranges. */ compare(withOther: DateRange): number; /** * Creates an iterable for every date in this range starting from the start date * until the end date (inclusive). * * By default every date is generated (amount = 1, interval = 'day'). \ * Increasing the interval between generated dates will always return the start date of this range * even if the next value lies beyond this range. */ iterate(amount?: number, interval?: PlainDateUnit): Iterable; }