unitsnet-js
Version:
A better way to hold unit variables and easily convert to the destination unit
279 lines (278 loc) • 9.64 kB
TypeScript
import { BaseUnit, ToStringOptions } from "../base-unit";
/** API DTO represents a Duration */
export interface DurationDto {
/** The value of the Duration */
value: number;
/** The specific unit that the Duration value is representing */
unit: DurationUnits;
}
/** DurationUnits enumeration */
export declare enum DurationUnits {
/** */
Years365 = "Year365",
/** */
Months30 = "Month30",
/** */
Weeks = "Week",
/** */
Days = "Day",
/** */
Hours = "Hour",
/** */
Minutes = "Minute",
/** */
Seconds = "Second",
/** */
JulianYears = "JulianYear",
/** */
Sols = "Sol",
/** */
Picoseconds = "Picosecond",
/** */
Nanoseconds = "Nanosecond",
/** */
Microseconds = "Microsecond",
/** */
Milliseconds = "Millisecond"
}
/** Time is a dimension in which events can be ordered from the past through the present into the future, and also the measure of durations of events and the intervals between them. */
export declare class Duration extends BaseUnit {
protected value: number;
private years365Lazy;
private months30Lazy;
private weeksLazy;
private daysLazy;
private hoursLazy;
private minutesLazy;
private secondsLazy;
private julianyearsLazy;
private solsLazy;
private picosecondsLazy;
private nanosecondsLazy;
private microsecondsLazy;
private millisecondsLazy;
/**
* Create a new Duration.
* @param value The value.
* @param fromUnit The ‘Duration’ unit to create from.
* The default unit is Seconds
*/
constructor(value: number, fromUnit?: DurationUnits);
/**
* The base value of Duration is Seconds.
* This accessor used when needs a value for calculations and it's better to use directly the base value
*/
get BaseValue(): number;
/** Gets the default unit used when creating instances of the unit or its DTO */
protected get baseUnit(): DurationUnits.Seconds;
/** */
get Years365(): number;
/** */
get Months30(): number;
/** */
get Weeks(): number;
/** */
get Days(): number;
/** */
get Hours(): number;
/** */
get Minutes(): number;
/** */
get Seconds(): number;
/** */
get JulianYears(): number;
/** */
get Sols(): number;
/** */
get Picoseconds(): number;
/** */
get Nanoseconds(): number;
/** */
get Microseconds(): number;
/** */
get Milliseconds(): number;
/**
* Create a new Duration instance from a Years365
*
* @param value The unit as Years365 to create a new Duration from.
* @returns The new Duration instance.
*/
static FromYears365(value: number): Duration;
/**
* Create a new Duration instance from a Months30
*
* @param value The unit as Months30 to create a new Duration from.
* @returns The new Duration instance.
*/
static FromMonths30(value: number): Duration;
/**
* Create a new Duration instance from a Weeks
*
* @param value The unit as Weeks to create a new Duration from.
* @returns The new Duration instance.
*/
static FromWeeks(value: number): Duration;
/**
* Create a new Duration instance from a Days
*
* @param value The unit as Days to create a new Duration from.
* @returns The new Duration instance.
*/
static FromDays(value: number): Duration;
/**
* Create a new Duration instance from a Hours
*
* @param value The unit as Hours to create a new Duration from.
* @returns The new Duration instance.
*/
static FromHours(value: number): Duration;
/**
* Create a new Duration instance from a Minutes
*
* @param value The unit as Minutes to create a new Duration from.
* @returns The new Duration instance.
*/
static FromMinutes(value: number): Duration;
/**
* Create a new Duration instance from a Seconds
*
* @param value The unit as Seconds to create a new Duration from.
* @returns The new Duration instance.
*/
static FromSeconds(value: number): Duration;
/**
* Create a new Duration instance from a JulianYears
*
* @param value The unit as JulianYears to create a new Duration from.
* @returns The new Duration instance.
*/
static FromJulianYears(value: number): Duration;
/**
* Create a new Duration instance from a Sols
*
* @param value The unit as Sols to create a new Duration from.
* @returns The new Duration instance.
*/
static FromSols(value: number): Duration;
/**
* Create a new Duration instance from a Picoseconds
*
* @param value The unit as Picoseconds to create a new Duration from.
* @returns The new Duration instance.
*/
static FromPicoseconds(value: number): Duration;
/**
* Create a new Duration instance from a Nanoseconds
*
* @param value The unit as Nanoseconds to create a new Duration from.
* @returns The new Duration instance.
*/
static FromNanoseconds(value: number): Duration;
/**
* Create a new Duration instance from a Microseconds
*
* @param value The unit as Microseconds to create a new Duration from.
* @returns The new Duration instance.
*/
static FromMicroseconds(value: number): Duration;
/**
* Create a new Duration instance from a Milliseconds
*
* @param value The unit as Milliseconds to create a new Duration from.
* @returns The new Duration instance.
*/
static FromMilliseconds(value: number): Duration;
/**
* Gets the base unit enumeration associated with Duration
* @returns The unit enumeration that can be used to interact with this type
*/
protected static getUnitEnum(): typeof DurationUnits;
/**
* Gets the default unit used when creating instances of the unit or its DTO
* @returns The unit enumeration value used as a default parameter in constructor and DTO methods
*/
protected static getBaseUnit(): DurationUnits.Seconds;
/**
* Create API DTO represent a Duration unit.
* @param holdInUnit The specific Duration unit to be used in the unit representation at the DTO
*/
toDto(holdInUnit?: DurationUnits): DurationDto;
/**
* Create a Duration unit from an API DTO representation.
* @param dtoDuration The Duration API DTO representation
*/
static FromDto(dtoDuration: DurationDto): Duration;
/**
* Convert Duration to a specific unit value.
* @param toUnit The specific unit to convert to
* @returns The value of the specific unit provided.
*/
convert(toUnit: DurationUnits): number;
private convertFromBase;
private convertToBase;
/**
* Format the Duration to string.
* Note! the default format for Duration is Seconds.
* To specify the unit format set the 'unit' parameter.
* @param unit The unit to format the Duration.
* @param options The ToString options, it also can be the number of fractional digits to keep that deprecated and moved to the options object. support in number will be dropped in the upcoming versions.
* @returns The string format of the Duration.
*/
toString(unit?: DurationUnits, options?: number | ToStringOptions): string;
/**
* Get Duration unit abbreviation.
* Note! the default abbreviation for Duration is Seconds.
* To specify the unit abbreviation set the 'unitAbbreviation' parameter.
* @param unitAbbreviation The unit abbreviation of the Duration.
* @returns The abbreviation string of Duration.
*/
getUnitAbbreviation(unitAbbreviation?: DurationUnits): string;
/**
* Check if the given Duration are equals to the current Duration.
* @param duration The other Duration.
* @returns True if the given Duration are equal to the current Duration.
*/
equals(duration: Duration): boolean;
/**
* Compare the given Duration against the current Duration.
* @param duration The other Duration.
* @returns 0 if they are equal, -1 if the current Duration is less then other, 1 if the current Duration is greater then other.
*/
compareTo(duration: Duration): number;
/**
* Add the given Duration with the current Duration.
* @param duration The other Duration.
* @returns A new Duration instance with the results.
*/
add(duration: Duration): Duration;
/**
* Subtract the given Duration with the current Duration.
* @param duration The other Duration.
* @returns A new Duration instance with the results.
*/
subtract(duration: Duration): Duration;
/**
* Multiply the given Duration with the current Duration.
* @param duration The other Duration.
* @returns A new Duration instance with the results.
*/
multiply(duration: Duration): Duration;
/**
* Divide the given Duration with the current Duration.
* @param duration The other Duration.
* @returns A new Duration instance with the results.
*/
divide(duration: Duration): Duration;
/**
* Modulo the given Duration with the current Duration.
* @param duration The other Duration.
* @returns A new Duration instance with the results.
*/
modulo(duration: Duration): Duration;
/**
* Pow the given Duration with the current Duration.
* @param duration The other Duration.
* @returns A new Duration instance with the results.
*/
pow(duration: Duration): Duration;
}