@toreda/time
Version:
Simple, small footprint library for common time operations and converting between units of time.
17 lines (16 loc) • 653 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.timeNow = timeNow;
const convert_1 = require("./convert");
const make_1 = require("./make");
/**
* Create a Time snapshot of the current system clock in `units`
* (defaults to seconds). The returned Time holds a frozen value
* captured at call time and does not auto-update.
*/
function timeNow(units) {
var _a;
const targetUnits = units !== null && units !== void 0 ? units : 's';
const value = (_a = (0, convert_1.timeConvert)('ms', targetUnits, Date.now())) !== null && _a !== void 0 ? _a : 0;
return (0, make_1.timeMake)(targetUnits, value);
}