@ts-common/azure-js-dev-tools
Version:
Developer dependencies for TypeScript related projects
91 lines • 2.82 kB
TypeScript
/**
* The different type of duration units.
*/
export declare type DurationUnits = "Milliseconds" | "Seconds" | "Minutes" | "Hours" | "Days" | "Weeks";
/**
* A class that represents a duration of time.
*/
export declare class Duration {
readonly value: number;
readonly units: DurationUnits;
/**
* Create a new Duration for the provided amount of milliseconds.
* @param value The numeric value of the Duration.
* @param units The units of the value for the Duration.
*/
constructor(value: number, units: DurationUnits);
/**
* Create a new Duration object with the provided number of milliseconds.
* @param value The number of milliseconds in the Duration.
*/
static milliseconds(value: number): Duration;
/**
* Create a new Duration object with the provided number of seconds.
* @param value The number of seconds in the Duration.
*/
static seconds(value: number): Duration;
/**
* Create a new Duration object with the provided number of minutes.
* @param value The number of minutes in the Duration.
*/
static minutes(value: number): Duration;
/**
* Create a new Duration object with the provided number of hours.
* @param value The number of hours in the Duration.
*/
static hours(value: number): Duration;
/**
* Create a new Duration object with the provided number of days.
* @param value The number of days in the Duration.
*/
static days(value: number): Duration;
/**
* Create a new Duration object with the provided number of weeks.
* @param value The number of weeks in the Duration.
*/
static weeks(value: number): Duration;
/**
* Convert this Duration to the provided DurationUnits.
*/
convertTo(targetUnits: DurationUnits): Duration;
/**
* Convert this Duration to milliseconds.
*/
toMilliseconds(): Duration;
/**
* Convert this Duration to seconds.
*/
toSeconds(): Duration;
/**
* Convert this Duration to minutes.
*/
toMinutes(): Duration;
/**
* Convert this Duration to hours.
*/
toHours(): Duration;
/**
* Convert this Duration to days.
*/
toDays(): Duration;
/**
* Convert this Duration to weeks.
*/
toWeeks(): Duration;
/**
* Get the string representation of this Duration.
*/
toString(): string;
/**
* Add this Duration to the provided Date.
* @param date The Date to add this Duration to.
* @returns The result of adding this Duration to the provided Date.
*/
plus(duration: Duration): Duration;
plus(date: Date): Date;
/**
* Get the current Date plus this Duration.
*/
fromNow(): Date;
}
//# sourceMappingURL=duration.d.ts.map