@toreda/time
Version:
Simple, small footprint library for common time operations and converting between units of time.
21 lines (20 loc) • 701 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.unixTimestampNow = void 0;
const defaults_1 = require("../../defaults");
/**
* Get the current time as a unix timestamp in number form.
* Does not create a Time object.
* @param offset Optional seconds to add or subtract from timestamp. No effect on
* on result when not provided.
* @returns Number of seconds since Unix Epoch.
*/
function unixTimestampNow(offset) {
const now = Math.floor(Date.now() / defaults_1.Defaults.Time.MsPerSec);
let result = now;
if (typeof offset === 'number') {
result += offset;
}
return result;
}
exports.unixTimestampNow = unixTimestampNow;