@roochnetwork/rooch-sdk-kit
Version:
Rooch SDK Kit
58 lines (56 loc) • 2.45 kB
JavaScript
;
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
// src/utils/time.ts
var time_exports = {};
__export(time_exports, {
getUTCOffset: () => getUTCOffset,
second2Countdown: () => second2Countdown,
unix2str: () => unix2str
});
module.exports = __toCommonJS(time_exports);
var import_dayjs = __toESM(require("dayjs"), 1);
function getUTCOffset() {
const date = /* @__PURE__ */ new Date();
const offset = -date.getTimezoneOffset();
const hours = Math.floor(offset / 60);
const minutes = offset % 60;
return `UTC ${hours >= 0 ? "+" : "-"}${hours}:${minutes < 10 ? "0" : ""}${minutes}`;
}
var unix2str = (input) => {
const timestampInSeconds = input > 1e12 ? input / 1e3 : input;
return `${import_dayjs.default.unix(timestampInSeconds).format("MMM DD, YYYY HH:mm:ss")}`;
};
var second2Countdown = (input) => {
const days = Math.floor(input / (24 * 3600));
const hours = Math.floor(input % (24 * 3600) / 3600);
const minutes = Math.floor(input % 3600 / 60);
const secs = Math.floor(input % 60);
return `${days} : ${hours} : ${minutes} : ${secs}`;
};
//# sourceMappingURL=time.js.map