UNPKG

@magicbell/core

Version:

Official MagicBell API wrapper

33 lines 893 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.secondsToDate = secondsToDate; exports.toDate = toDate; exports.toUnix = toUnix; const tslib_1 = require("tslib"); const dayjs_1 = tslib_1.__importDefault(require("dayjs")); /** * Function to build a Date given a number of seconds. * * @example secondsToDate(1582263571) */ function secondsToDate(seconds) { return seconds ? toDate(seconds * 1000) : null; } /** * Function to build a Date given a string or number of milliseconds. * * @example toDate('2020-02-01') */ function toDate(date) { return (0, dayjs_1.default)(date); } /** * Function to return a UNIX timestamp from a date representation. This value is * floored to the nearest second. * * @example toUnix('2020-10-06') */ function toUnix(date) { return (0, dayjs_1.default)(date).unix(); } //# sourceMappingURL=date.js.map