@aplus-frontend/ui
Version:
24 lines (23 loc) • 845 B
JavaScript
function f(n, o) {
const t = n.split("|");
return t.length === 1 ? `${o} ${n}` : `${o} ${o > 1 ? t[1].trim() : t[0].trim()}`;
}
function g(n, o) {
const t = o.ap.timeAgo, i = {
s: t.second,
m: t.minute,
h: t.hour,
d: t.days,
M: t.months,
y: t.years
}, { unit: r, count: a, type: l } = n;
let e = i[n.unit], s = !0;
if (r === "s" && n.count < 10 ? (e = t.justNow, s = !1) : r === "d" && a === 1 ? (e = l === "ago" ? t.yesterday : t.tomorrow, s = !1) : r === "M" && a === 1 ? (e = l === "ago" ? t.lastMonth : t.nextMonth, s = !1) : r === "y" && a === 1 && (e = l === "ago" ? t.lastYear : t.nextYear, s = !1), !s)
return e;
const u = l === "ago" ? t.ago : t.late;
return e = `${f(e, a)} ${u}`, o.name === "zh-cn" && (e = e.replace(/\s+/g, "")), e;
}
export {
f as getCountWord,
g as getTimeAgoStr
};