UNPKG

press-shared

Version:
59 lines (58 loc) 1.01 kB
const u = { // 毫秒 get S() { return 1; }, // 秒 get s() { return this.S * 1e3; }, // 分 get m() { return this.s * 60; }, // 时 get h() { return this.m * 60; }, // 天 get d() { return this.h * 24; }, // 周 get w() { return this.d * 7; }, // 月 get mo() { return this.d * 30; }, get y() { return this.d * 365; } }; function a(r, n = "h") { const s = u[n], e = /* @__PURE__ */ new Date(); return [new Date(e.getTime() - r * s), e]; } function t(r, n, s, e) { return { type: e, text: s, value: a(r, n) }; } function o() { return [ t(0.5, "h", "最近半小时", "last0.5Hour"), t(1, "h", "最近一小时", "last1Hour"), t(3, "h", "最近三小时", "last3Hour"), t(6, "h", "最近六小时", "last6Hour"), t(1, "d", "最近一天", "last1Day"), t(3, "d", "最近三天", "last3Day"), t(1, "w", "最近一周", "last1Week") ]; } export { o as createDateRangeShortcuts };