From 340737f2a8f7fcc17326cc9caa072adeea271f3c Mon Sep 17 00:00:00 2001 From: Jm Casler Date: Mon, 11 Apr 2022 18:53:29 -0700 Subject: [PATCH] Work around for issue with unknown age due to not having time Work around for issue with unknown age due to not having time --- src/graphics/Screen.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/graphics/Screen.cpp b/src/graphics/Screen.cpp index 0ac19cbce..0ccc46b22 100644 --- a/src/graphics/Screen.cpp +++ b/src/graphics/Screen.cpp @@ -668,8 +668,18 @@ static void drawNodeInfo(OLEDDisplay *display, OLEDDisplayUiState *state, int16_ snprintf(lastStr, sizeof(lastStr), "%u seconds ago", agoSecs); else if (agoSecs < 120 * 60) // last 2 hrs snprintf(lastStr, sizeof(lastStr), "%u minutes ago", agoSecs / 60); - else - snprintf(lastStr, sizeof(lastStr), "%u hours ago", agoSecs / 60 / 60); + else { + + uint32_t hours_in_month = 730; + + // Only show hours ago if it's been less than 6 months. Otherwise, we may have bad + // data. + if ((agoSecs / 60 / 60) < (hours_in_month * 6)) { + snprintf(lastStr, sizeof(lastStr), "%u hours ago", agoSecs / 60 / 60); + } else { + snprintf(lastStr, sizeof(lastStr), "unknown age"); + } + } static char distStr[20]; strcpy(distStr, "? km"); // might not have location data