dash-core
Version:
A foundational toolkit of types, collections, services, and architectural patterns designed to accelerate application development.
97 lines (96 loc) • 3.36 kB
TypeScript
/**
* Represents a time interval measured in milliseconds.
*/
export declare class TimeSpan {
private readonly ms;
/**
* Initializes a new instance of the TimeSpan class.
* @param milliseconds Number of milliseconds in the interval. Must be ≥ 0.
* @throws Error if `milliseconds` is negative.
*/
constructor(milliseconds?: number);
/**
* Gets a TimeSpan representing zero milliseconds.
* @returns A TimeSpan of 0 milliseconds.
*/
static zero(): TimeSpan;
/**
* Creates a new TimeSpan from an existing one.
* @param timeSpan The source TimeSpan to copy.
* @returns A new TimeSpan with the same duration as `timeSpan`.
*/
static fromTimeSpan(timeSpan: TimeSpan): TimeSpan;
/**
* Creates a TimeSpan for the specified number of days.
* @param days Number of days.
* @returns A TimeSpan equal to `days` 24 hours.
*/
static fromDays(days: number): TimeSpan;
/**
* Creates a TimeSpan for the specified number of hours.
* @param hours Number of hours.
* @returns A TimeSpan equal to `hours` 60 minutes.
*/
static fromHours(hours: number): TimeSpan;
/**
* Creates a TimeSpan for the specified number of minutes.
* @param minutes Number of minutes.
* @returns A TimeSpan equal to `minutes` 60 seconds.
*/
static fromMinutes(minutes: number): TimeSpan;
/**
* Creates a TimeSpan for the specified number of seconds.
* @param seconds Number of seconds.
* @returns A TimeSpan equal to `seconds` 1000 milliseconds.
*/
static fromSeconds(seconds: number): TimeSpan;
/**
* Creates a TimeSpan for the specified number of milliseconds.
* @param milliseconds Number of milliseconds.
* @returns A TimeSpan equal to `milliseconds`.
*/
static fromMilliseconds(milliseconds: number): TimeSpan;
/**
* Gets the total number of milliseconds in this interval.
*/
get totalMilliseconds(): number;
/**
* Gets the total number of seconds in this interval, including fractional.
*/
get totalSeconds(): number;
/**
* Gets the total number of minutes in this interval, including fractional.
*/
get totalMinutes(): number;
/**
* Gets the total number of hours in this interval, including fractional.
*/
get totalHours(): number;
/**
* Gets the total number of days in this interval, including fractional.
*/
get totalDays(): number;
/**
* Adds another TimeSpan to this one.
* @param other The interval to add.
* @returns A new TimeSpan equal to the sum of this and `other`.
*/
add(other: TimeSpan): TimeSpan;
/**
* Subtracts another TimeSpan from this one.
* @param other The interval to subtract.
* @returns A new TimeSpan equal to the difference of this and `other`.
*/
subtract(other: TimeSpan): TimeSpan;
/**
* Determines whether this TimeSpan is equal to another.
* @param other The TimeSpan to compare.
* @returns `true` if both intervals have the same duration; otherwise, `false`.
*/
equals(other: TimeSpan): boolean;
/**
* Returns the primitive value (milliseconds) of this TimeSpan.
* Enables using `+` or comparisons directly on instances.
*/
valueOf(): number;
}