修复订单显示bug
This commit is contained in:
@@ -196,3 +196,28 @@ export function formatTime(dateStr: string): string {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 格式化日期时间为可读字符串
|
||||
* @param value ISO 格式的日期字符串
|
||||
* @returns 格式化后的日期时间字符串(当年:MM-DD HH:mm,跨年:YYYY-MM-DD HH:mm)
|
||||
*/
|
||||
export function formatDateTime(value: string): string {
|
||||
if (value == '') return ''
|
||||
const parsed = Date.parse(value)
|
||||
if (!isNaN(parsed)) {
|
||||
const date = new Date(parsed)
|
||||
const currentYear = new Date().getFullYear()
|
||||
const year = date.getFullYear()
|
||||
const month = String(date.getMonth() + 1).padStart(2, '0')
|
||||
const day = String(date.getDate()).padStart(2, '0')
|
||||
const hour = String(date.getHours()).padStart(2, '0')
|
||||
const minute = String(date.getMinutes()).padStart(2, '0')
|
||||
if (year == currentYear) {
|
||||
return month + '-' + day + ' ' + hour + ':' + minute
|
||||
} else {
|
||||
return year + '-' + month + '-' + day + ' ' + hour + ':' + minute
|
||||
}
|
||||
}
|
||||
return value
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user