@barchart/common-js
Version:
Library of common JavaScript utilities
168 lines (167 loc) • 4.14 kB
TypeScript
/**
* A data structure that represents a time of day (hours, minutes, seconds),
* without consideration for date or timezone.
*
* @public
*/
export default class Time {
/**
* Returns true if the hours, minutes, and seconds combination is valid.
*
* @public
* @static
* @param {number} hours
* @param {number} minutes
* @param {number} seconds
* @returns {boolean}
*/
public static validate(hours: number, minutes: number, seconds: number): boolean;
/**
* Parses a string in the format "hh:mm:ss" and returns a Time instance.
*
* @public
* @static
* @param {string} time
* @returns {Time}
*/
public static parse(time: string): Time;
/**
* Creates a {@link Time} from the hours, minutes, and seconds properties (in local time)
* of the {@link Date} argument.
*
* @public
* @static
* @param {Date} date
* @returns {Time}
*/
public static fromDate(date: Date): Time;
/**
* Creates a {@link Time} from the hours, minutes, and seconds properties (in UTC)
* of the {@link Date} argument.
*
* @public
* @static
* @param {Date} date
* @returns {Time}
*/
public static fromDateUtc(date: Date): Time;
/**
* @param {number} hours
* @param {number} minutes
* @param {number} seconds
*/
constructor(hours: number, minutes: number, seconds: number);
/**
* The hours (0–23).
*
* @public
* @returns {number}
*/
public get hours(): number;
/**
* The minutes (0–59).
*
* @public
* @returns {number}
*/
public get minutes(): number;
/**
* The seconds (0–59).
*
* @public
* @returns {number}
*/
public get seconds(): number;
/**
* @public
* @param {*} seconds
* @returns {Time}
*/
public addSeconds(seconds: any): Time;
/**
* Returns a new {@link Time} instance with some number of seconds subtracted.
*
* @public
* @param {number} seconds
* @returns {Time}
*/
public subtractSeconds(seconds: number): Time;
/**
* Returns a new {@link Time} instance with some number of minutes added.
*
* @public
* @param {number} minutes
* @returns {Time}
*/
public addMinutes(minutes: number): Time;
/**
* Returns a new {@link Time} instance with some number of minutes subtracted.
*
* @public
* @param {number} minutes
* @returns {Time}
*/
public subtractMinutes(minutes: number): Time;
/**
* Returns a new {@link Time} instance with some number of minutes added.
*
* @public
* @param {number} hours
* @returns {Time}
*/
public addHours(hours: number): Time;
/**
* Returns a new {@link Time} instance with some number of minutes subtracted.
*
* @public
* @param {number} hours
* @returns {Time}
*/
public subtractHours(hours: number): Time;
/**
* Indicates if the current {@link Time} instance is before another time.
*
* @public
* @param {Time} other
* @returns {boolean}
*/
public getIsBefore(other: Time): boolean;
/**
* Indicates if the current {@link Time} instance is after another time.
*
* @public
* @param {Time} other
* @returns {boolean}
*/
public getIsAfter(other: Time): boolean;
/**
* Indicates if the current {@link Time} instance is the same as another time.
*
* @public
* @param {Time} other
* @returns {boolean}
*/
public getIsEqual(other: Time): boolean;
/**
* Outputs the time as the formatted string: {hh}:{mm}:{ss}.
*
* @public
* @returns {string}
*/
public format(): string;
/**
* Returns the JSON representation.
*
* @public
* @returns {string}
*/
public toJSON(): string;
/**
* Returns a string representation.
*
* @public
* @returns {string}
*/
public toString(): string;
#private;
}