UNPKG

@toreda/time

Version:

Simple, small footprint library for common time operations and converting between units of time.

17 lines (16 loc) 663 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.timeSince = timeSince; const now_1 = require("./now"); /** * Time elapsed since `time`. Negative when `time` is in the future. * Numbers are interpreted as a unix timestamp in seconds. The returned * Time uses `units` (defaults to seconds). Returns null when input is * invalid or the computed result falls outside the safe integer range. * * @param time Reference Time instance, or unix timestamp in seconds. * @param units Units for the returned Time. Defaults to `'s'`. */ function timeSince(time, units = 's') { return (0, now_1.timeNow)(units).since(time); }