UNPKG

@signumjs/util

Version:

Useful utilities and tools for building Signum Network applications

63 lines (62 loc) 1.77 kB
/** * Original work Copyright (c) 2020 Burst Apps Team * Modfied work Copyright (c) 2021 Signum Network */ /** * A Value Object to facilitate Chain Timestamp conversions. * * @category value-objects */ export declare class ChainTime { private _chainTimestamp; private constructor(); /** * Creates a Block Time object from Chain Time Stamp * @param timestamp The timestamp from Chain */ static fromChainTimestamp(timestamp: number): ChainTime; /** * Creates a Block Time object from Date * @param date Any Date object */ static fromDate(date: Date): ChainTime; /** * @return Gets Chain Timestamp representation */ getChainTimestamp(): number; /** * Sets ChainTime using Chain Timestamp */ setChainTimestamp(blockTimestamp: number): void; /** * @return Time in seconds since 01.01.1970 */ getEpoch(): number; /** * @return real Date representation */ getDate(): Date; /** * Sets blockTime using native Date * @param date Any Date object */ setDate(date: Date): void; /** * Checks for equality * @param chainTime The other value to be compared * @return true if equal, otherwise false */ equals(chainTime: ChainTime): boolean; /** * Checks if a chainTime is before a given one * @param chainTime The other value to be compared * @return true if _before_ a given chainTime, otherwise false */ before(chainTime: ChainTime): boolean; /** * Checks if a chainTime is after a given one * @param chainTime The other value to be compared * @return true if _after_ a given chainTime, otherwise false */ after(chainTime: ChainTime): boolean; }