将 44901.3576388889 excel读取的时间戳 转换为 2022-12-06 08:28
/**
* @param {number} time 传入的时间
* @param {blob} format 拼接方式 '-'
*/
export function excelFormatDate(time, format) {
const time = new Date(((time-70*365-19)*86400-8*3600)*1000)
const year = time.getFullYear() + ''
const month = time.getMonth() + 1 + ''
const date = time.getDate() + ''
let h = time.getHours()
h = h < 10 ? ('0' + h) : h
let m = time.getMinutes()
m = m < 10 ? ('0' + m) : m
let s = time.getSeconds()
s = s < 10 ? ('0' + s) : s
if (format && format.length === 1) {
return year + format + month + format + date + ' ' + h + ':' + m + ':' + s
}
return year + (month < 10 ? '0' + month : month) + (date < 10 ? '0' + date : date) + ' ' + h + ':' + m + ':' + s
}