epoch-seconds
Version:
Returns the amount of seconds passed since Unix epoch (1970 UTC).
28 lines (25 loc) • 1.1 kB
TypeScript
/**
* @return Seconds passed since Unix epoch (January 1, 1970, UTC (same as GMT+0))
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/now
* @example const now = epochSeconds()
*/
export declare const epochSeconds: {
(): NonNegativeInteger<number>;
/**
* @return Seconds passed since Unix epoch (January 1, 1970, UTC (same as GMT+0)) with as much fractional precision as possible
* @see https://developer.mozilla.org/en-US/docs/Web/API/Performance/now
* @see https://nodejs.org/api/perf_hooks.html#performancenow
* @example const now = epochSeconds.precise()
*/
precise(): NonNegative<number>;
};
type Integer<T extends number> = `${T}` extends `${bigint}` ? T : never;
type Negative<T extends Numeric> = T extends Zero ? never : `${T}` extends `-${string}` ? T : never;
type NonNegative<T extends Numeric> = T extends Zero ? T : Negative<T> extends never ? T : never;
type NonNegativeInteger<T extends number> = NonNegative<Integer<T>>;
type Numeric = number | bigint;
type Zero = 0 | 0n;
export {
epochSeconds as default,
};
export {};