UNPKG

@fast-china/utils

Version:

Fast 工具库.

3 lines (2 loc) 3.04 kB
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t={getGreet(){const t=(new Date).getHours();let e="";return e=t<5?"夜深了,注意身体哦!":t<9?"早上好!欢迎回来!":t<12?"上午好!欢迎回来!":t<14?"中午好!欢迎回来!":t<18?"下午好!欢迎回来!":t<24?"晚上好!欢迎回来!":"您好!欢迎回来!",e},dateTimeFix(t){if(null!=t&&t){"string"==typeof t&&(t=new Date(t));let e=t.getTime();if(e.toString().length<13){const t=e.toString().split("");for(let e=0;e<13;e++)t[e]||(t[e]="0");e=parseInt(t.join(""))}const s=6e4,n=60*s,r=24*n,a=30*r,o=(new Date).getTime()-e,u=o/a,D=o/(7*r),l=o/r,g=o/n,w=o/s;if(o<0){const t=Math.abs(u),e=Math.abs(D),s=Math.abs(l),n=Math.abs(g),r=Math.abs(w);return t>12?`${parseInt(""+t/12)}年后`:t>=6?"半年后":t>=1?`${parseInt(`${t}`)}月后`:e>2?"半月后":e>=1?`${parseInt(`${e}`)}周后`:s>=1?`${parseInt(`${s}`)}天后`:n>=1?`${parseInt(`${n}`)}小时后`:r>=1?`${parseInt(`${r}`)}分钟后`:"刚刚"}return u>12?`${parseInt(""+u/12)}年前`:u>=6?"半年前":u>=1?`${parseInt(`${u}`)}月前`:D>2?"半月前":D>=1?`${parseInt(`${D}`)}周前`:l>=1?`${parseInt(`${l}`)}天前`:g>=1?`${parseInt(`${g}`)}小时前`:w>=1?`${parseInt(`${w}`)}分钟前`:"刚刚"}return""},getDefaultTime(){const t=new Date,e=new Date;return e.setMonth(e.getMonth()-1),e.setHours(0,0,0),t.setHours(23,59,59),[e,t]},getSimpleTime(){const t=new Date;return t.setHours(0,0,0),t},getSimpleShortcuts:()=>[{text:"今天",value:()=>{const t=new Date;return t.setHours(0,0,0),t}},{text:"昨天",value:()=>{const t=new Date;return t.setDate(t.getDate()-1),t.setHours(0,0,0),t}},{text:"一周前",value:()=>{const t=new Date;return t.setDate(t.getDate()-7),t.setHours(0,0,0),t}},{text:"一月前",value:()=>{const t=new Date;return t.setMonth(t.getMonth()-1),t.setHours(0,0,0),t}},{text:"一年前",value:()=>{const t=new Date;return t.setFullYear(t.getFullYear()-1),t.setHours(0,0,0),t}}],getShortcuts:()=>[{text:"近1天",value:()=>{const t=new Date,e=new Date;return e.setDate(e.getDate()-1),e.setHours(0,0,0),t.setHours(23,59,59),[e,t]}},{text:"近3天",value:()=>{const t=new Date,e=new Date;return e.setDate(e.getDate()-3),e.setHours(0,0,0),t.setHours(23,59,59),[e,t]}},{text:"近1周",value:()=>{const t=new Date,e=new Date;return e.setDate(e.getDate()-7),e.setHours(0,0,0),t.setHours(23,59,59),[e,t]}},{text:"近1月",value:()=>{const t=new Date,e=new Date;return e.setMonth(e.getMonth()-1),e.setHours(0,0,0),t.setHours(23,59,59),[e,t]}},{text:"近3月",value:()=>{const t=new Date,e=new Date;return e.setMonth(e.getMonth()-3),e.setHours(0,0,0),t.setHours(23,59,59),[e,t]}},{text:"近6月",value:()=>{const t=new Date,e=new Date;return e.setMonth(e.getMonth()-6),e.setHours(0,0,0),t.setHours(23,59,59),[e,t]}},{text:"近1年",value:()=>{const t=new Date,e=new Date;return e.setFullYear(e.getFullYear()-1),e.setHours(0,0,0),t.setHours(23,59,59),[e,t]}}],getDisabledDate:t=>t.getTime()>Date.now()};exports.dateUtil=t; //# sourceMappingURL=index.js.map