From 27ff17b2adcd060e500a03ab972d0ff27a7ceda2 Mon Sep 17 00:00:00 2001 From: "torlando-agent[bot]" <281092095+torlando-agent[bot]@users.noreply.github.com> Date: Mon, 22 Jun 2026 17:07:10 -0400 Subject: [PATCH] fix(gps): Arizona no-DST carve-out + raise unsynced-display threshold to 2024 Addresses Greptile review on #36: - Arizona is inside the Mountain longitude band but doesn't observe DST (and it straddles the Mountain/Pacific boundary), so MST7MDT wrongly showed MDT in summer. It now gets an explicit MST7 (no-DST) carve-out by lat/lon box before the longitude bands. (The DST-observing Navajo Nation is not separately handled.) - The Settings "Time:" display used a >= 2016 threshold, which let the ESP32's ~2016-01-01 first-boot default render as a real date instead of "not set". Raised to >= 2024 so an unsynced clock is visibly unsynced. Co-Authored-By: Claude Opus 4.8 (1M context) Claude-Session: https://claude.ai/code/session_01UWZuYkHBRqNb6BZHV8sTG5 --- lib/tdeck_ui/UI/LXMF/SettingsScreen.cpp | 2 +- src/main.cpp | 13 ++++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/lib/tdeck_ui/UI/LXMF/SettingsScreen.cpp b/lib/tdeck_ui/UI/LXMF/SettingsScreen.cpp index 321c248e..853016f8 100644 --- a/lib/tdeck_ui/UI/LXMF/SettingsScreen.cpp +++ b/lib/tdeck_ui/UI/LXMF/SettingsScreen.cpp @@ -1219,7 +1219,7 @@ void SettingsScreen::update_gps_display() { time_t now = time(nullptr); struct tm lt; localtime_r(&now, <); - if (lt.tm_year + 1900 >= 2016) { + if (lt.tm_year + 1900 >= 2024) { // < 2024 == unsynced (1970 or the ESP32 ~2016 boot default) char tbuf[48]; strftime(tbuf, sizeof(tbuf), "Time: %Y-%m-%d %H:%M:%S", <); lv_label_set_text(_label_gps_time, tbuf); diff --git a/src/main.cpp b/src/main.cpp index 0e18ae54..6a06f767 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -320,12 +320,19 @@ bool sync_time_from_gps(uint32_t timeout_ms = 30000) { // US bands use POSIX strings WITH DST rules, so summer correctly shows EDT/CDT/ // MDT/PDT instead of standard time. The old code used a raw longitude offset with // no DST rule, so e.g. Eastern showed EST in June (1h slow). Outside those bands, - // fall back to a plain longitude offset (no DST) -- which is also correct for - // non-DST regions like Arizona/Puerto Rico that a blanket rule would get wrong. + // fall back to a plain longitude offset (no DST) -- correct for non-DST / non-US + // regions like Puerto Rico. Arizona (Mountain band, no DST) gets a carve-out below. double longitude = gps.location.lng(); + double latitude = gps.location.lat(); const char* tz_str; char tz_buf[32]; - if (longitude >= -82.5 && longitude < -67.0) tz_str = "EST5EDT,M3.2.0,M11.1.0"; // Eastern + // Arizona (excl. the Navajo Nation) is MST year-round -- no DST -- AND straddles + // the Mountain/Pacific longitude boundary, so check its lat/lon box before the + // longitude bands. Approximate box; the DST-observing Navajo Nation in the NE + // corner is not separately handled. + if (latitude >= 31.3 && latitude <= 37.0 && longitude >= -114.9 && longitude <= -109.0) + tz_str = "MST7"; // Arizona: no DST + else if (longitude >= -82.5 && longitude < -67.0) tz_str = "EST5EDT,M3.2.0,M11.1.0"; // Eastern else if (longitude >= -97.5 && longitude < -82.5) tz_str = "CST6CDT,M3.2.0,M11.1.0"; // Central else if (longitude >= -112.5 && longitude < -97.5) tz_str = "MST7MDT,M3.2.0,M11.1.0"; // Mountain else if (longitude >= -127.5 && longitude < -112.5) tz_str = "PST8PDT,M3.2.0,M11.1.0"; // Pacific