袁聪的前端调修
This commit is contained in:
@@ -12,12 +12,18 @@ export function formatPercent(value) {
|
||||
return `${number > 0 ? '+' : ''}${number.toFixed(2)}%`;
|
||||
}
|
||||
|
||||
export function formatDateTime(value) {
|
||||
export function formatDateTime(value, includeSeconds = false) {
|
||||
if (!value) return '--';
|
||||
const date = new Date(value);
|
||||
if (Number.isNaN(date.getTime())) return String(value);
|
||||
return new Intl.DateTimeFormat('zh-CN', {
|
||||
year: 'numeric', month: '2-digit', day: '2-digit', hour: '2-digit', minute: '2-digit', hour12: false,
|
||||
year: 'numeric',
|
||||
month: '2-digit',
|
||||
day: '2-digit',
|
||||
hour: '2-digit',
|
||||
minute: '2-digit',
|
||||
...(includeSeconds ? { second: '2-digit' } : {}),
|
||||
hour12: false,
|
||||
}).format(date).replaceAll('/', '-');
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user