@barchart/common-js
Version:
Library of common JavaScript utilities
105 lines (104 loc) • 2.64 kB
TypeScript
/**
* A data structure that represents the time between two dates.
*
* @public
*/
export default class Timespan {
/**
* Creates a new {@link Timespan} instance from dates.
*
* @public
* @static
* @param {Date} start
* @param {Date} end
* @returns {Timespan}
*/
public static fromDates(start: Date, end: Date): Timespan;
/**
* @param {number} start
* @param {number} end
*/
constructor(start: number, end: number);
/**
* The start time (as milliseconds since epoch).
*
* @public
* @returns {number}
*/
public get start(): number;
/**
* The start time (as milliseconds since epoch).
*
* @public
* @returns {number}
*/
public get end(): number;
/**
* The total number of days between the start and end times (rounded down to the nearest integer).
*
* @public
* @returns {number}
*/
public get days(): number;
/**
* The total number of hours between the start and end times (rounded down to the nearest integer).
*
* @public
* @returns {number}
*/
public get hours(): number;
/**
* The total number of minutes between the start and end times (rounded down to the nearest integer).
*
* @public
* @returns {number}
*/
public get minutes(): number;
/**
* The total number of seconds between the start and end times (rounded down to the nearest integer).
*
* @public
* @returns {number}
*/
public get seconds(): number;
/**
* The total number of milliseconds between the start and end times.
*
* @public
* @returns {number}
*/
public get milliseconds(): number;
/**
* Returns the duration between the start and end times as days, hours, minutes, seconds, and
* milliseconds.
*
* @public
* @param {boolean} days
* @param {boolean} hours
* @param {boolean} minutes
* @param {boolean} seconds
* @returns {{days: number, hours: number, minutes: *, seconds: number, milliseconds: number}}
*/
public getDuration(days: boolean, hours: boolean, minutes: boolean, seconds: boolean): {
days: number;
hours: number;
minutes: any;
seconds: number;
milliseconds: number;
};
/**
* Returns the JSON representation.
*
* @public
* @returns {object}
*/
public toJSON(): object;
/**
* Returns a string representation.
*
* @public
* @returns {string}
*/
public toString(): string;
#private;
}