UNPKG

@aplus-frontend/ui

Version:

2 lines (1 loc) 712 B
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function i(o,r){const t=o.split("|");return t.length===1?`${r} ${o}`:`${r} ${r>1?t[1].trim():t[0].trim()}`}function f(o,r){const t=r.ap.timeAgo,u={s:t.second,m:t.minute,h:t.hour,d:t.days,M:t.months,y:t.years},{unit:s,count:a,type:l}=o;let e=u[o.unit],n=!0;if(s==="s"&&o.count<10?(e=t.justNow,n=!1):s==="d"&&a===1?(e=l==="ago"?t.yesterday:t.tomorrow,n=!1):s==="M"&&a===1?(e=l==="ago"?t.lastMonth:t.nextMonth,n=!1):s==="y"&&a===1&&(e=l==="ago"?t.lastYear:t.nextYear,n=!1),!n)return e;const g=l==="ago"?t.ago:t.late;return e=`${i(e,a)} ${g}`,r.name==="zh-cn"&&(e=e.replace(/\s+/g,"")),e}exports.getCountWord=i;exports.getTimeAgoStr=f;