feat: show max temperature time in METAR display

This commit is contained in:
AmandaloveYang
2026-02-16 11:09:56 +08:00
parent c4fc26314d
commit d4314ff5d7
2 changed files with 13 additions and 1 deletions
+5
View File
@@ -260,6 +260,7 @@ class WeatherDataCollector:
utc_midnight = local_midnight - timedelta(seconds=utc_offset)
max_so_far_c = -999
max_temp_time = None
for obs in data:
obs_report_time = obs.get("reportTime", "")
try:
@@ -271,6 +272,9 @@ class WeatherDataCollector:
t = obs.get("temp")
if t is not None and t > max_so_far_c:
max_so_far_c = t
# 转为当地时间并记录
local_report = report_dt + timedelta(seconds=utc_offset)
max_temp_time = local_report.strftime("%H:%M")
except:
continue
@@ -295,6 +299,7 @@ class WeatherDataCollector:
"current": {
"temp": round(temp, 1) if temp is not None else None,
"max_temp_so_far": round(max_so_far, 1) if max_so_far is not None else None,
"max_temp_time": max_temp_time,
"dewpoint": round(dewp, 1) if dewp is not None else None,
"humidity": latest.get("rh"),
"wind_speed_kt": latest.get("wspd"),