time-offset
Version:
Accumulative Time Calculator: A simple calculator for time offsets that provides methods to manipulate and retrieve time values.
88 lines (87 loc) • 3.18 kB
TypeScript
/**
* Library for work over time in seconds. The library works in accumulative mode, essentially a calculator.
*/
export declare class TimeOffset {
constructor(ttl?: number);
private _ttl;
valueOf(): number;
/**
* Creates an object with 0 seconds and adds the indicated seconds
*
* Next values need to be indicated. By default, all values are rounded down. It is allowed to use negative values
* @param {number} seconds
* @return {TimeOffset}
*/
static addSeconds(seconds: number): TimeOffset;
/**
* Adds to the current accumulated time the indicated seconds
*
* Next values need to be indicated. By default, all values are rounded down. It is allowed to use negative values
* @param {number} seconds
* @return {TimeOffset}
*/
addSeconds(seconds: number): TimeOffset;
/**
* Creates an object with 0 seconds and adds the indicated minutes
*
* Next values need to be indicated. By default, all values are rounded down. It is allowed to use negative values
* @param {number} minutes
* @return {TimeOffset}
*/
static addMinutes(minutes: number): TimeOffset;
/**
* Adds to the current accumulated time the indicated minutes
*
* Next values need to be indicated. By default, all values are rounded down. It is allowed to use negative values
* @param {number} minutes
* @return {TimeOffset}
*/
addMinutes(minutes: number): TimeOffset;
/**
* Creates an object with 0 seconds and adds the specified watches
*
* Next values need to be indicated. By default, all values are rounded down. It is allowed to use negative values
* @param {number} hours
* @return {TimeOffset}
*/
static addHours(hours: number): TimeOffset;
/**
* Adds to the current accumulated time specified hours
*
* Next values need to be indicated. By default, all values are rounded down. It is allowed to use negative values
* @param {number} hours
* @return {TimeOffset}
*/
addHours(hours: number): TimeOffset;
/**
* Creates an object with 0 seconds and adds the indicated days
*
* Next values need to be indicated. By default, all values are rounded down. It is allowed to use negative values
* @param {number} days
* @return {TimeOffset}
*/
static addDays(days: number): TimeOffset;
/**
* Adds to the current accumulated time indicated days
*
* Next values need to be indicated. By default, all values are rounded down. Allowed to use negative values
* @param {number} days
* @return {TimeOffset}
*/
addDays(days: number): TimeOffset;
/**
* Returns the accumulated time in seconds
* @return {number}
*/
toAccumulatedSeconds(): number;
/**
* Uses the accumulated seconds and returns the date in the future. `new Date(Date.now() + (ttl * 1000))`
* @return {Date}
*/
toFutureDate(): Date;
/**
* Uses the accumulated seconds and returns the date in the past. `new Date(Date.now() - (ttl * 1000))`
* @return {Date}
*/
toDatePast(): Date;
}