Improve nearby station timing labels

This commit is contained in:
2569718930@qq.com
2026-04-19 02:44:18 +08:00
parent fbbd13b1c3
commit b16a8b51b6
2 changed files with 5 additions and 5 deletions
@@ -2162,10 +2162,10 @@
display: flex; display: flex;
align-items: center; align-items: center;
gap: 4px; gap: 4px;
margin-top: 2px; margin-top: 3px;
font-size: 8px; font-size: 10px;
font-weight: 700; font-weight: 700;
color: rgba(148, 163, 184, 0.88); color: rgba(203, 213, 225, 0.95);
white-space: nowrap; white-space: nowrap;
} }
+2 -2
View File
@@ -140,13 +140,13 @@ function buildNearbyIconHtml(detail: CityDetail, station: NearbyStation) {
const symbol = detail.temp_symbol || "°C"; const symbol = detail.temp_symbol || "°C";
const formatObsTime = () => { const formatObsTime = () => {
const label = String(station.obs_time_label || "").trim(); const label = String(station.obs_time_label || "").trim();
if (label) return label; if (label) return label.replace(/Z$/i, "");
const raw = String(station.obs_time || "").trim(); const raw = String(station.obs_time || "").trim();
if (!raw) return ""; if (!raw) return "";
if (raw.endsWith("Z") || raw.includes("+00:00")) { if (raw.endsWith("Z") || raw.includes("+00:00")) {
const parsed = new Date(raw); const parsed = new Date(raw);
if (!Number.isNaN(parsed.getTime())) { if (!Number.isNaN(parsed.getTime())) {
return `${String(parsed.getUTCHours()).padStart(2, "0")}:${String(parsed.getUTCMinutes()).padStart(2, "0")}Z`; return `${String(parsed.getUTCHours()).padStart(2, "0")}:${String(parsed.getUTCMinutes()).padStart(2, "0")}`;
} }
} }
if (raw.includes("T")) return raw.split("T").pop()?.slice(0, 5) || ""; if (raw.includes("T")) return raw.split("T").pop()?.slice(0, 5) || "";