(timeStr: string)
| 111 | return "pagermaid"; |
| 112 | } |
| 113 | |
| 114 | // 格式化时间为中文显示 |
| 115 | function formatChineseTime(timeStr: string): string { |
| 116 | try { |
| 117 | // 匹配各种时间格式 |
| 118 | // 如: "Sat 2025-08-02 19:56:44 CST" |
| 119 | const timePatterns = [ |
| 120 | /(\w+)\s+(\d{4}-\d{2}-\d{2})\s+(\d{2}:\d{2}:\d{2})\s+(\w+)/, |
| 121 | /(\d{4}-\d{2}-\d{2})\s+(\d{2}:\d{2}:\d{2})/ |
| 122 | ]; |
| 123 | |
| 124 | for (const pattern of timePatterns) { |
| 125 | const match = timeStr.match(pattern); |
| 126 | if (match) { |
| 127 | if (match.length === 5) { // 有星期和时区 |
| 128 | const [, weekday, date, time, timezone] = match; |
| 129 | const cnWeekday = WEEKDAY_MAP[weekday] || weekday; |
| 130 | |
| 131 | // 如果是CST,明确标注为北京时间 |
| 132 | if (timezone === "CST") { |
| 133 | return `${cnWeekday} ${date} ${time} (北京时间)`; |
| 134 | } else { |
| 135 | return `${cnWeekday} ${date} ${time} (${timezone})`; |
| 136 | } |
| 137 | } else { // 只有日期时间 |
| 138 | const [, date, time] = match; |
| 139 | return `${date} ${time} (北京时间)`; |
| 140 | } |
| 141 | } |
| 142 | } |
| 143 | |
| 144 | // 如果匹配失败,返回原始字符串 |
| 145 | return timeStr; |
| 146 | } catch (error) { |
| 147 | return timeStr; |
| 148 | } |
| 149 | } |
| 150 |
no outgoing calls
no test coverage detected