d74fc74f28
Create utils/format.ts with toBeijing() helper. Replace 13 raw .slice().replace() date displays in admin.vue with centralized timezone-aware formatting. Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
18 lines
441 B
TypeScript
18 lines
441 B
TypeScript
/** 将 ISO 时间字符串转为北京时间(UTC+8)显示 */
|
|
export function toBeijing(iso?: string): string {
|
|
if (!iso) return '--'
|
|
try {
|
|
return new Date(iso).toLocaleString('zh-CN', {
|
|
timeZone: 'Asia/Shanghai',
|
|
hour12: false,
|
|
year: 'numeric',
|
|
month: '2-digit',
|
|
day: '2-digit',
|
|
hour: '2-digit',
|
|
minute: '2-digit',
|
|
})
|
|
} catch {
|
|
return iso.slice(0, 16).replace('T', ' ')
|
|
}
|
|
}
|