exportconst formatTime =( time: number | string, formats =''):string=>{functionzero(n: number):string {return n <10?'0'+ n :String(n)}if(!time){
time =newDate().getTime()}// 10位数的时间戳if(Number(time)<9999999999){
time =Number(time)*1000}const date =newDate(time)const year =String(date.getFullYear())const month =zero(date.getMonth()+1)const day =zero(date.getDate())const hour =zero(date.getHours())const minute =zero(date.getMinutes())const second =zero(date.getSeconds())constdateMap:{[key:string]: string}={Y: year,M: month,D: day,h: hour,m: minute,s: second
}return formats.replace(/Y|m|d|H|i|s/ig,(matches:string | number |undefined)=>{return dateMap[String(matches)]})}
exportfunction deepCopy<T>(list:T):T{let copyList
switch(getType(list)){case"array":
copyList =[]breakcase"object":
copyList ={}breakdefault:return list
}for(let i in list){
copyList =deepCopy(list[i])}return list
}