@barchart/common-js
Version:
Library of common JavaScript utilities
131 lines (130 loc) • 3.29 kB
TypeScript
/**
* An immutable data structure that encapsulates a Unix timestamp (in
* milliseconds).
*
* @public
*/
export default class Timestamp {
/**
* Clones a {@link Timestamp} instance.
*
* @public
* @static
* @param {Timestamp} other
* @returns {Timestamp}
*/
public static clone(other: Timestamp): Timestamp;
/**
* Parses the value emitted by {@link Timestamp#toJSON}.
*
* @public
* @static
* @param {number} value
* @returns {Timestamp}
*/
public static parse(value: number): Timestamp;
/**
* Returns a new {@link Timestamp} instance, representing the current moment.
*
* @public
* @static
* @returns {Timestamp}
*/
public static now(): Timestamp;
/**
* A comparator function for {@link Timestamp} instances.
*
* @public
* @static
* @param {Timestamp} a
* @param {Timestamp} b
* @returns {number}
*/
public static compareTimestamps(a: Timestamp, b: Timestamp): number;
/**
* @param {number} timestamp
*/
constructor(timestamp: number);
/**
* The timestamp (milliseconds since epoch).
*
* @public
* @returns {number}
*/
public get timestamp(): number;
/**
* Returns a new {@link Timestamp} instance shifted forward by a specific
* number of milliseconds.
*
* @public
* @param {number} milliseconds
* @returns {Timestamp}
*/
public add(milliseconds: number): Timestamp;
/**
* Returns a new {@link Timestamp} instance shifted backwards by a specific
* number of milliseconds.
*
* @public
* @param {number} milliseconds
* @returns {Timestamp}
*/
public subtract(milliseconds: number): Timestamp;
/**
* Returns a new {@link Timestamp} instance shifted forward by a specific
* number of seconds.
*
* @public
* @param {number} seconds
* @returns {Timestamp}
*/
public addSeconds(seconds: number): Timestamp;
/**
* Returns a new {@link Timestamp} instance shifted backwards by a specific
* number of seconds.
*
* @public
* @param {number} seconds
* @returns {Timestamp}
*/
public subtractSeconds(seconds: number): Timestamp;
/**
* Indicates if the current {@link Timestamp} instance occurs before another timestamp.
*
* @public
* @param {Timestamp} other
* @returns {boolean}
*/
public getIsBefore(other: Timestamp): boolean;
/**
* Indicates if the current {@link Timestamp} instance occurs after another timestamp.
*
* @public
* @param {Timestamp} other
* @returns {boolean}
*/
public getIsAfter(other: Timestamp): boolean;
/**
* Indicates if another {@link Timestamp} refers to the same moment.
*
* @public
* @param {Timestamp} other
* @returns {boolean}
*/
public getIsEqual(other: Timestamp): boolean;
/**
* Returns the JSON representation.
*
* @public
* @returns {number}
*/
public toJSON(): number;
/**
* Returns a string representation.
*
* @public
* @returns {string}
*/
public toString(): string;
#private;
}