import { CalendarDateOrTime } from './date'; export type DurationUnit = 'W' | 'D' | 'H' | 'M' | 'S'; /** * Represents a DURATION value as defined by RFC5545. */ export declare class CalendarDuration { weeks?: number; days?: number; hours?: number; minutes?: number; seconds?: number; constructor(duration: string | CalendarDuration); /** * Get the length of this duration object in seconds. * @returns The total number of seconds represented by this duration. */ inSeconds(): number; /** * Get the length of this duration object in milliseconds. * * Note that this will always return whole seconds, as durations do not * support milliseconds. * @returns The total number of milliseconds represented by this duration. */ inMilliseconds(): number; /** * Get the duration string that represents this duration. * @returns A duration string in the format `P[n]W` for weeks, or `P[n]DT[n]H[n]M[n]S` for days, hours, minutes and seconds. Prefixed with a `-` if negative. */ getValue(): string; /** * Get the floor the duration to the nearest of a given unit. * @param unit The unit to floor to. * @returns The duration with units smaller than `unit` removed. * @example * const duration = new CalendarDuration("1W2D5H30M") * const days = duration.floor("D") // Floor to days * console.log(days.getValue()) // "1W2D" */ floor(unit: DurationUnit): CalendarDuration; /** * Create a duration from a number of seconds. * @param seconds How many seconds the duration should represent. * @returns A {@link CalendarDuration} representing the specified number of seconds. * @throws {Error} If seconds is NaN. */ static fromSeconds(seconds: number): CalendarDuration; /** * Create a duration from a number of days. * @param days How many days the duration should represent. * @returns A {@link CalendarDuration} representing the specified number of days. * @throws {Error} If days is NaN. */ static fromDays(days: number): CalendarDuration; /** * Create a duration from a number of weeks. * @param weeks How many weeks the duration should represent. * @returns A {@link CalendarDuration} representing the specified number of weeks. * @throws {Error} If weeks is NaN. */ static fromWeeks(weeks: number): CalendarDuration; /** * Creates a duration from the difference between two dates. * @param start The start date or time. * @param end The end date or time. * @returns A {@link CalendarDuration} representing the difference between the two dates. * @throws {Error} If the start date and end date have different types. */ static fromDifference(start: Date | CalendarDateOrTime, end: Date | CalendarDateOrTime): CalendarDuration; } /** * Convert time units to a duration string. * * A duration is considered negative if any unit is less than 0. * @param weeks How many weeks the duration should represent. * @param days The days part of the duration. * @param hours The hours part of the duration. * @param minutes The minutes part of the duration. * @param seconds The seconds part of the duration. * @returns A string representing the duration in the format `P[n]W` or `P[n]DT[n]H[n]M[n]S` where values may be omitted if 0, prefixed with `-` if negative. * @throws {Error} If weeks are combined with other values. * @throws {Error} If any unit is NaN. */ export declare function formatDurationString(weeks: number | undefined, days: number | undefined, hours: number | undefined, minutes: number | undefined, seconds: number | undefined): string; /** * Convert a number of seconds to a duration string. * @param seconds How many seconds the duration should represent. * @returns A string representing the duration in the format `PT[n]H[n]M[n]S` where values may be omitted if 0, prefixed with `-` if negative. * @throws {Error} If seconds is NaN. */ export declare function secondsToDurationString(seconds: number): string; /** * Convert a number of days to a duration string. * @param days How many days the duration should represent. * @returns A string representing the duration in the format `P[n]D`, prefixed with `-` if negative. * @throws {Error} If days is NaN. */ export declare function daysToDurationString(days: number): string; /** * Convert a number of weeks to a duration string. * @param weeks How many weeks the duration should represent. * @returns A string representing the duration in the format `P[n]W`, prefixed with `-` if negative. * @throws {Error} If weeks is NaN. */ export declare function weeksToDurationString(weeks: number): string; //# sourceMappingURL=duration.d.ts.map