date.js 1.2 KB

1
  1. "use strict";function g(r){const e=r;let o,u,a,t;return e>=3600?(u=parseInt(`${e/3600}`,10)<10?`0${parseInt(`${e/3600}`,10)}`:parseInt(`${e/3600}`,10),a=parseInt(`${e%60/60}`,10)<10?`0${parseInt(`${e%60/60}`,10)}`:parseInt(`${e%60/60}`,10),t=e%3600<10?`0${e%3600}`:e%3600,t>60&&(a=parseInt(`${t/60}`,10)<10?`0${parseInt(`${t/60}`,10)}`:parseInt(`${t/60}`,10),t=t%60<10?`0${t%60}`:t%60),o=`${u}:${a}:${t}`):e>=60&&e<3600?(a=parseInt(`${e/60}`,10)<10?`0${parseInt(`${e/60}`,10)}`:parseInt(`${e/60}`,10),t=e%60<10?`0${e%60}`:e%60,o=`00:${a}:${t}`):e<60&&(t=e<10?`0${e}`:e,o=`00:00:${t}`),o}function h(r){const s=new Date().getTime()-r;let $="";if(s<0)return;const i=s/6e4,c=s/36e5,l=s/864e5,f=s/6048e5;if(f>=1&&f<=4)$=` ${parseInt(`${f}`,10)}\u5468\u524D`;else if(l>=1&&l<=6)$=` ${parseInt(`${l}`,10)}\u5929\u524D`;else if(c>=1&&c<=23)$=` ${parseInt(`${c}`,10)}\u5C0F\u65F6\u524D`;else if(i>=1&&i<=59)$=` ${parseInt(`${i}`,10)}\u5206\u949F\u524D`;else if(s>=0&&s<=6e4)$="\u521A\u521A";else{const n=new Date;n.setTime(r);const m=n.getFullYear(),I=n.getMonth()+1<10?`0${n.getMonth()+1}`:n.getMonth()+1,p=n.getDate()<10?`0${n.getDate()}`:n.getDate();$=`${m}-${I}-${p}`}return $}exports.caculateTimeago=h;exports.formatTime=g;