// 公共工具函数 const TIMEZONE = 'Asia/Shanghai'; function timestamp() { return new Date().toLocaleString('zh-CN', { timeZone: TIMEZONE, hour12: false }); } function normalizeTime(str) { if (!str) return timestamp(); if (/\d{4}\/\d{1,2}\/\d{1,2} \d{2}:\d{2}:\d{2}/.test(str)) return str; const clean = str.replace(/-/g, '/'); if (/^\d{4}\/\d{1,2}\/\d{1,2}$/.test(clean)) return clean + ' 00:00:00'; const withSlash = str.replace(/-/g, '/'); if (/\d{4}\/\d{1,2}\/\d{1,2} \d{2}:\d{2}:\d{2}/.test(withSlash)) return withSlash; return timestamp(); } module.exports = { timestamp, normalizeTime };