import { type DateRelativeState, type FractionalHour, type Minutes, type Maybe } from '@dereekb/util'; import { type DateRange } from './date.range'; /** * Represents a time span with a start date and a duration in minutes. * * Used throughout the date cell system to define when events begin and how long they last. */ export interface DateDurationSpan { startsAt: Date; duration: Minutes; } /** * Computes the end date for a duration span by adding the duration to the start time. * * @param span - Span whose end date should be computed. * @returns Moment when the span ends. * * @dbxUtil * @dbxUtilCategory date * @dbxUtilTags date, duration, span, end, compute, time * @dbxUtilRelated duration-span-to-date-range, duration-span-from-date-range * * @example * ```ts * const span = { startsAt: new Date('2024-01-01T10:00:00Z'), duration: 60 }; * dateDurationSpanEndDate(span); // 2024-01-01T11:00:00Z * ``` */ export declare function dateDurationSpanEndDate(span: DateDurationSpan): Date; /** * Converts a {@link DateDurationSpan} to a {@link DateRange} with start and end dates. * * @param span - Span to project onto a start/end date range. * @returns Range from startsAt to startsAt + duration. * * @dbxUtil * @dbxUtilCategory date * @dbxUtilTags date, duration, span, range, convert * @dbxUtilRelated date-duration-span-end-date, duration-span-from-date-range */ export declare function durationSpanToDateRange(span: DateDurationSpan): DateRange; /** * Creates a {@link DateDurationSpan} from a {@link DateRange} by computing the duration in minutes between start and end. * * @param dateRange - Range to project onto a duration span. * @returns Span anchored at the range's start with duration measured to its end. * * @dbxUtil * @dbxUtilCategory date * @dbxUtilTags date, duration, span, range, convert, minutes * @dbxUtilRelated duration-span-to-date-range, date-duration-span-end-date */ export declare function durationSpanFromDateRange(dateRange: DateRange): DateDurationSpan; /** * Determines whether a duration span is in the past, present, or future relative to the given time. * * @param span - The duration span to check. * @param now - Reference time (defaults to current time) * @returns 'past', 'present', or 'future'. */ export declare function durationSpanDateRelativeState(span: DateDurationSpan, now?: Date): DateRelativeState; /** * Converts a duration span's duration from minutes to fractional hours. * * @param span - The duration span to measure. * @returns The duration expressed as fractional hours (e.g. 90 minutes = 1.5) */ export declare function fractionalHoursInDurationSpan(span: DateDurationSpan): FractionalHour; /** * Null-safe equality check for two {@link DateDurationSpan} values, comparing both startsAt and duration. * * @param a - first span * @param b - second span * @returns whether the spans are equal (or both nullish) */ export declare function isSameDurationSpan(a: DateDurationSpan, b: DateDurationSpan): boolean; export declare function isSameDurationSpan(a: Maybe, b: Maybe): boolean;