CN-599 feat: 新报告功能

This commit is contained in:
chenjinsong
2022-06-08 18:32:52 +08:00
parent 996adc1483
commit e516258a2a
9 changed files with 131 additions and 63 deletions

View File

@@ -44,9 +44,9 @@ export function rTime (date) {
// 时间格式转换
export function dateFormat (date, format = 'YYYY-MM-DD HH:mm:ss') {
let d = date
// date不是数字则视为时间字符串例如2022-02-22 22:22
// date不是数字则视为utc时区的时间字符串例如2022-02-22 22:22
if (isNaN(date)) {
d = window.$dayJs(date).valueOf() + parseInt(localStorage.getItem('cn-timezone-local-offset'))
d = window.$dayJs(date).valueOf() + parseInt(localStorage.getItem(storageKey.timezoneLocalOffset)) * 3600000
} else {
d = getMillisecond(date)
}
@@ -57,3 +57,15 @@ export function dateFormat (date, format = 'YYYY-MM-DD HH:mm:ss') {
export function dateFormatByAppearance (date) {
return dateFormat(date, localStorage.getItem(storageKey.dateFormat))
}
// 带时区的日期转为utc日期
export function dateFormatToUTC (date, format = 'YYYY-MM-DD HH:mm:ss') {
let d = date
// date不是数字则视为utc时区的时间字符串例如2022-02-22 22:22
if (isNaN(date)) {
d = window.$dayJs(date).valueOf() - parseInt(localStorage.getItem(storageKey.timezoneLocalOffset)) * 3600000
} else {
d = getMillisecond(date)
}
d = window.$dayJs(d).tz().format(format)
return d
}