@cmstops/pro-compo
Version:
[物料平台文档中心](https://arco.design/docs/material/guide)
30 lines (29 loc) • 889 B
JavaScript
;
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
function tow(n) {
return n >= 0 && n < 10 ? `0${n}` : `${n}`;
}
function need(value, label) {
if (!value)
return "";
return tow(value) + label;
}
function getSpaceDate(date) {
const oDate = new Date();
const oldTime = oDate.getTime();
const newDate = new Date(date);
const newTime = newDate.getTime();
let second = Math.floor((newTime - oldTime) / 1e3);
if (second <= 0) {
return 0;
}
const day = Math.floor(second / 86400);
second %= 86400;
const hour = Math.floor(second / 3600);
second %= 3600;
const minute = Math.floor(second / 60);
second %= 60;
const str = `${need(day, "\u5929") + need(hour, "\u5C0F\u65F6") + need(minute, "\u5206\u949F") + tow(second)}\u79D2`;
return str;
}
exports.getSpaceDate = getSpaceDate;