UNPKG

@toreda/time

Version:

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

18 lines (17 loc) 603 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.timeUntil = void 0; const convert_1 = require("./convert"); const make_1 = require("./make"); const now_1 = require("./now"); function timeUntil(time) { const output = (0, make_1.timeMake)('s', 0); const now = (0, now_1.timeNow)(); const future = typeof time === 'number' ? time : (0, convert_1.timeConvert)(time.units(), 's', time()); if (future === null) { return output; } const result = future - now(); return (0, make_1.timeMake)('s', result); } exports.timeUntil = timeUntil;