From 6b68cb7c61466c3947f9c08085c85ba95d585cee Mon Sep 17 00:00:00 2001 From: proddy Date: Sun, 19 Apr 2026 15:12:22 +0200 Subject: [PATCH] store UTC epoch time and convert to localtime when render (fixes bug as TZ not set) --- interface/src/i18n/cz/index.ts | 4 ++-- interface/src/i18n/de/index.ts | 4 ++-- interface/src/i18n/en/index.ts | 4 ++-- interface/src/i18n/fr/index.ts | 4 ++-- interface/src/i18n/it/index.ts | 4 ++-- interface/src/i18n/nl/index.ts | 4 ++-- interface/src/i18n/no/index.ts | 4 ++-- interface/src/i18n/pl/index.ts | 4 ++-- interface/src/i18n/sk/index.ts | 4 ++-- interface/src/i18n/sv/index.ts | 4 ++-- interface/src/i18n/tr/index.ts | 2 +- src/core/system.cpp | 27 ++++++++++++++++----------- src/core/system.h | 2 +- src/web/WebStatusService.cpp | 21 +++++++++++++++------ 14 files changed, 53 insertions(+), 39 deletions(-) diff --git a/interface/src/i18n/cz/index.ts b/interface/src/i18n/cz/index.ts index 28b958301..fbce09041 100644 --- a/interface/src/i18n/cz/index.ts +++ b/interface/src/i18n/cz/index.ts @@ -350,7 +350,7 @@ const cz: Translation = { NO_DATA_1: 'Nebyly nalezeny žádné oblíbené entity. Použijte modul', NO_DATA_2: 'pro jejich výběr.', NO_DATA_3: 'Pro zobrazení všech dostupných entit navštivte stránku', - NO_GPIO:'Nebylo nalezeno žádné volné GPIO', + NO_GPIO: 'Nebylo nalezeno žádné volné GPIO', THIS_VERSION: 'Tato verze', PLATFORM: 'Platforma', RELEASE_TYPE: 'Typ sestavení', @@ -362,7 +362,7 @@ const cz: Translation = { STORED_VERSIONS: 'Uložené verze', ONLINE_HELP: 'online nápověda', UPGRADE_IMPORTANT_MESSAGES: 'Aktualizovat důležité zprávy', - UPGRADE_IMPORTANT_MESSAGES_1: 'Tato aktualizace vyžaduje obnovení továrního nastavení. Ujistěte se, že jste vytvořili zálohu své konfigurace a nastavení před pokračováním a nahrajte ji po instalaci nové verze.', + UPGRADE_IMPORTANT_MESSAGES_1: 'Tato aktualizace vyžaduje obnovení továrního nastavení. Ujistěte se, že nejprve stáhnete systémovou zálohu před pokračováním a poté nahrajte tento soubor po instalaci nové verze.', UPGRADE_IMPORTANT_MESSAGES_2: 'Aktualizujete se na novou hlavní verzi. Ujistěte se, že jste přečetli ChangeLog pro jakékoliv závažné změny.', WARNING_SYSTEM_BACKUP: 'Toto vytvoří zálohu vašich celých systémových konfigurací a nastavení. Všechna hesla budou v zálohovém souboru čitelná. Buďte opatrní při sdílení! Opravdu chcete pokračovat?' diff --git a/interface/src/i18n/de/index.ts b/interface/src/i18n/de/index.ts index e8d17c01b..4a9710e1d 100644 --- a/interface/src/i18n/de/index.ts +++ b/interface/src/i18n/de/index.ts @@ -350,7 +350,7 @@ const de: Translation = { NO_DATA_1: 'Keine favorisierten EMS-Entitäten gefunden! Verwenden Sie das Modul', NO_DATA_2: ', um sie zu markieren.', NO_DATA_3: 'Um alle verfügbaren Entitäten anzuzeigen, gehen Sie zu', - NO_GPIO:'Keine freien GPIO gefunden', + NO_GPIO: 'Keine freien GPIO gefunden', THIS_VERSION: 'Diese Version', PLATFORM: 'Plattform', RELEASE_TYPE: 'Release Typ', @@ -362,7 +362,7 @@ const de: Translation = { STORED_VERSIONS: 'Gespeicherte Versionen', ONLINE_HELP: 'Online-Hilfe', UPGRADE_IMPORTANT_MESSAGES: 'Wichtige Nachrichten aktualisieren', - UPGRADE_IMPORTANT_MESSAGES_1: 'Diese Aktualisierung erfordert eine Werkseinstellung. Stellen Sie sicher, dass Sie eine Sicherung Ihrer Konfiguration und Einstellungen vor dem Fortfahren erstellt haben und diese nach der Installation der neuen Version hochladen.', + UPGRADE_IMPORTANT_MESSAGES_1: 'Diese Aktualisierung erfordert eine Werkseinstellung. Stellen Sie sicher, dass Sie zuerst eine Systemsicherung herunterladen, bevor Sie fortfahren, und laden Sie diese Datei dann nach der Installation der neuen Version hoch.', UPGRADE_IMPORTANT_MESSAGES_2: 'Sie aktualisieren auf eine neue Hauptversion. Stellen Sie sicher, dass Sie den ChangeLog für alle wichtigen Änderungen gelesen haben.', WARNING_SYSTEM_BACKUP: 'Dies wird eine Sicherung Ihrer vollständigen Systemkonfiguration und -einstellungen erstellen. Alle Passwörter werden im Sicherungsdatei lesbar sein. Seien Sie vorsichtig beim Teilen! Möchten Sie fortfahren?' diff --git a/interface/src/i18n/en/index.ts b/interface/src/i18n/en/index.ts index 0c116d399..610ed0f00 100644 --- a/interface/src/i18n/en/index.ts +++ b/interface/src/i18n/en/index.ts @@ -350,7 +350,7 @@ const en: Translation = { NO_DATA_1: 'No favorite EMS entities found yet. Use the', NO_DATA_2: 'module to mark them.', NO_DATA_3: 'To see all available entities go to', - NO_GPIO:'No available GPIO found', + NO_GPIO: 'No available GPIO found', THIS_VERSION: 'This Version', PLATFORM: 'Platform', RELEASE_TYPE: 'Release Type', @@ -362,7 +362,7 @@ const en: Translation = { STORED_VERSIONS: 'Stored Versions', ONLINE_HELP: 'online help', UPGRADE_IMPORTANT_MESSAGES: 'Upgrade Important Messages', - UPGRADE_IMPORTANT_MESSAGES_1: 'This upgrade requires a factory reset. Make sure you have made a backup of your configuration and settings before continuing, and upload this after the new version is installed.', + UPGRADE_IMPORTANT_MESSAGES_1: 'This upgrade requires a factory reset. Make sure you first download a System Backup before continuing, and then upload this file after the new version is installed.', UPGRADE_IMPORTANT_MESSAGES_2: 'You are upgrading to a new major version. Make sure you have read the ChangeLog for any breaking changes.', WARNING_SYSTEM_BACKUP: 'This will create a backup of your full system configuration and settings. All passwords will be readable in the backup file. Be careful with sharing! Do you want to continue?' diff --git a/interface/src/i18n/fr/index.ts b/interface/src/i18n/fr/index.ts index 528c83bd9..f1945d2ab 100644 --- a/interface/src/i18n/fr/index.ts +++ b/interface/src/i18n/fr/index.ts @@ -350,7 +350,7 @@ const fr: Translation = { NO_DATA_1: 'Aucune entité EMS favorite trouvée. Utilisez le', NO_DATA_2: 'module pour les marquer.', NO_DATA_3: 'Pour voir toutes les entités disponibles, aller à', - NO_GPIO:"Aucun GPIO disponible n'a été détecté", + NO_GPIO: "Aucun GPIO disponible n'a été détecté", THIS_VERSION: 'Cette version', PLATFORM: 'Plateforme', RELEASE_TYPE: 'Type de version', @@ -362,7 +362,7 @@ const fr: Translation = { STORED_VERSIONS: 'Versions stockées', ONLINE_HELP: 'aide en ligne', UPGRADE_IMPORTANT_MESSAGES: 'Mettre à jour les messages importants', - UPGRADE_IMPORTANT_MESSAGES_1: 'Cette mise à jour nécessite une réinitialisation de fabrique. Assurez-vous d\'avoir créé une sauvegarde de vos configurations et paramètres avant de continuer et de la charger après l\'installation de la nouvelle version.', + UPGRADE_IMPORTANT_MESSAGES_1: 'Cette mise à jour nécessite une réinitialisation de fabrique. Assurez-vous de télécharger une sauvegarde système avant de continuer, et de la charger après l\'installation de la nouvelle version.', UPGRADE_IMPORTANT_MESSAGES_2: 'Vous mettez à jour vers une nouvelle version majeure. Assurez-vous de lire le ChangeLog pour tout changement important.', WARNING_SYSTEM_BACKUP: 'Cela créera une sauvegarde de votre configuration et paramètres complets. Tous les mots de passe seront lisibles dans le fichier de sauvegarde. Soyez prudent avec le partage ! Voulez-vous continuer ?' diff --git a/interface/src/i18n/it/index.ts b/interface/src/i18n/it/index.ts index 04fe977d2..df8b4de61 100644 --- a/interface/src/i18n/it/index.ts +++ b/interface/src/i18n/it/index.ts @@ -350,7 +350,7 @@ const it: Translation = { NO_DATA_1: 'Nessuna entità EMS preferita trovata. Usa il', NO_DATA_2: 'modulo per marcarle.', NO_DATA_3: 'Per vedere tutte le entità disponibili vai a', - NO_GPIO:'Non è stato trovato alcun GPIO disponibile', + NO_GPIO: 'Non è stato trovato alcun GPIO disponibile', THIS_VERSION: 'Questa versione', PLATFORM: 'Piattaforma', RELEASE_TYPE: 'Tipo di rilascio', @@ -362,7 +362,7 @@ const it: Translation = { STORED_VERSIONS: 'Versioni memorizzate', ONLINE_HELP: 'aiuto online', UPGRADE_IMPORTANT_MESSAGES: 'Aggiorna Messaggi Importanti', - UPGRADE_IMPORTANT_MESSAGES_1: 'Questa aggiornamento richiede un ripristino di fabbrica. Assicurati di aver creato un backup delle tue configurazioni e impostazioni prima di continuare e di caricarlo dopo l\'installazione della nuova versione.', + UPGRADE_IMPORTANT_MESSAGES_1: 'Questa aggiornamento richiede un ripristino di fabbrica. Assicurati di prima scaricare un backup del sistema prima di continuare, e poi caricare questo file dopo l\'installazione della nuova versione.', UPGRADE_IMPORTANT_MESSAGES_2: 'Stai aggiornando a una nuova versione principale. Assicurati di aver letto il ChangeLog per qualsiasi cambiamento importante.', WARNING_SYSTEM_BACKUP: 'Questo creerà un backup delle tue configurazioni e impostazioni complete. Tutte le password saranno leggibili nel file di backup. Sei sicuro di voler continuare?' diff --git a/interface/src/i18n/nl/index.ts b/interface/src/i18n/nl/index.ts index 70176a084..888c033d8 100644 --- a/interface/src/i18n/nl/index.ts +++ b/interface/src/i18n/nl/index.ts @@ -350,7 +350,7 @@ const nl: Translation = { NO_DATA_1: 'Er zijn nog geen favoriete EMS-entiteiten gevonden. Gebruik de', NO_DATA_2: 'module om ze te markeren.', NO_DATA_3: 'Om alle beschikbare entiteiten te zien, ga naar', - NO_GPIO:'Er is geen beschikbare GPIO gevonden', + NO_GPIO: 'Er is geen beschikbare GPIO gevonden', THIS_VERSION: 'Deze Versie', PLATFORM: 'Platform', RELEASE_TYPE: 'Release Typ', @@ -362,7 +362,7 @@ const nl: Translation = { STORED_VERSIONS: 'Opgeslagen versies', ONLINE_HELP: 'online help', UPGRADE_IMPORTANT_MESSAGES: 'Upgrade Belangrijke Berichten', - UPGRADE_IMPORTANT_MESSAGES_1: 'Deze upgrade vereist een fabrieksinstelling. Zorg ervoor dat u een back-up van uw configuratie en instellingen hebt gemaakt voordat u doorgaat en upload deze na de installatie van de nieuwe versie.', + UPGRADE_IMPORTANT_MESSAGES_1: 'Deze upgrade vereist een fabrieksinstelling. Zorg ervoor dat u eerst een Systeem Backup download voordat u doorgaat, en upload deze file na de installatie van de nieuwe versie.', UPGRADE_IMPORTANT_MESSAGES_2: 'U updatet naar een nieuwe grote versie. Zorg ervoor dat u de ChangeLog hebt gelezen voor alle brekende wijzigingen.', WARNING_SYSTEM_BACKUP: 'Dit zal een back-up van uw volledige systeemconfiguratie en instellingen maken. Alle wachtwoorden zijn leesbaar in het back-upbestand. Wees voorzichtig bij delen! Wilt u doorgaan?' diff --git a/interface/src/i18n/no/index.ts b/interface/src/i18n/no/index.ts index f37f87d99..693ef29e8 100644 --- a/interface/src/i18n/no/index.ts +++ b/interface/src/i18n/no/index.ts @@ -350,7 +350,7 @@ const no: Translation = { NO_DATA_1: 'Ingen favoritte EMS enheter funnet enda. Bruk', NO_DATA_2: 'modul for å markere dem.', NO_DATA_3: 'For å se alle tilgjengelige enheter, gå til', - NO_GPIO:'Det ble ikke funnet noen tilgjengelige GPIO-porter', + NO_GPIO: 'Det ble ikke funnet noen tilgjengelige GPIO-porter', THIS_VERSION: 'Denne versjonen', PLATFORM: 'Plattform', RELEASE_TYPE: 'Utgivelses type', @@ -362,7 +362,7 @@ const no: Translation = { STORED_VERSIONS: 'Lagret versjoner', ONLINE_HELP: 'online hjelp', UPGRADE_IMPORTANT_MESSAGES: 'Oppdater viktige meldinger', - UPGRADE_IMPORTANT_MESSAGES_1: 'Denne oppdateringen krever en fabriksinstilling. Sørg for at du har laget en sikkerhetskopi av din konfigurasjon og innstillinger før du fortsetter, og last denne opp etter at den nye versjonen er installert.', + UPGRADE_IMPORTANT_MESSAGES_1: 'Denne oppdateringen krever en fabriksinstilling. Sørg for at du først lastet ned en System Backup før du fortsetter, og last denne filen etter at den nye versjonen er installert.', UPGRADE_IMPORTANT_MESSAGES_2: 'Du oppdaterer til en ny hovedversjon. Sørg for at du har lest ChangeLog for eventuelle bruddende endringer.', WARNING_SYSTEM_BACKUP: 'Dette vil lage en sikkerhetskopi av din fullstendige systemkonfigurasjon og innstillinger. Alle passord vil være lesbare i sikkerhetskopien. Vær forsiktig med deling! Vil du fortsette?' diff --git a/interface/src/i18n/pl/index.ts b/interface/src/i18n/pl/index.ts index 5a279ba93..c6dd004de 100644 --- a/interface/src/i18n/pl/index.ts +++ b/interface/src/i18n/pl/index.ts @@ -350,7 +350,7 @@ const pl: BaseTranslation = { NO_DATA_1: 'Brak ulubionych encji EMS. Użyj', NO_DATA_2: 'moduł do ich oznaczenia.', NO_DATA_3: 'Aby zobaczyć wszystkie dostępne encje przejdź do', - NO_GPIO:'Nie znaleziono dostępnych pinów GPIO', + NO_GPIO: 'Nie znaleziono dostępnych pinów GPIO', THIS_VERSION: 'Ta wersja', PLATFORM: 'Platforma', RELEASE_TYPE: 'Typ wydania', @@ -362,7 +362,7 @@ const pl: BaseTranslation = { STORED_VERSIONS: 'Zapisane wersje', ONLINE_HELP: 'pomoc online', UPGRADE_IMPORTANT_MESSAGES: 'Aktualizuj ważne wiadomości', - UPGRADE_IMPORTANT_MESSAGES_1: 'Ta aktualizacja wymaga resetu fabrycznego. Upewnij się, że masz utworzoną kopię swoich ustawień i konfiguracji przed kontynuowaniem i przesuń ją po zainstalowaniu nowej wersji.', + UPGRADE_IMPORTANT_MESSAGES_1: 'Ta aktualizacja wymaga resetu fabrycznego. Upewnij się, że najpierw pobierzesz kopię zapasową systemu przed kontynuowaniem, a następnie przesuń tę plik po zainstalowaniu nowej wersji.', UPGRADE_IMPORTANT_MESSAGES_2: 'Aktualizujesz się do nowej głównej wersji. Upewnij się, że przeczytałeś ChangeLog dla wszelkich istotnych zmian.', WARNING_SYSTEM_BACKUP: 'To spowoduje utworzenie kopii zapasowej całej konfiguracji i ustawień systemu. Wszystkie hasła będą widoczne w pliku kopii zapasowej. Bądź ostrożny przy udostępnianiu! Chcesz kontynuować?' diff --git a/interface/src/i18n/sk/index.ts b/interface/src/i18n/sk/index.ts index be742048f..5e993e998 100644 --- a/interface/src/i18n/sk/index.ts +++ b/interface/src/i18n/sk/index.ts @@ -350,7 +350,7 @@ const sk: Translation = { NO_DATA_1: 'Nenašli sa žiadne obľúbené entity EMS. Použite', NO_DATA_2: 'modul na ich označenie.', NO_DATA_3: 'Ak chcete zobraziť všetky dostupné entity, prejdite na', - NO_GPIO:'Nebol nájdený žiadny dostupný GPIO', + NO_GPIO: 'Nebol nájdený žiadny dostupný GPIO', THIS_VERSION: 'Táto verzia', PLATFORM: 'Platforma', RELEASE_TYPE: 'Typ vydania', @@ -362,7 +362,7 @@ const sk: Translation = { STORED_VERSIONS: 'Uložené verzie', ONLINE_HELP: 'online pomoc', UPGRADE_IMPORTANT_MESSAGES: 'Aktualizovať dôležité správy', - UPGRADE_IMPORTANT_MESSAGES_1: 'Táto aktualizácia vyžaduje reštart základných nastavení. Uistite sa, že ste vytvorili zálohu svojich konfigurácií a nastavení pred pokračovaním a nahrajte ju po instalácii novej verzie.', + UPGRADE_IMPORTANT_MESSAGES_1: 'Táto aktualizácia vyžaduje reštart základných nastavení. Uistite sa, že najprv stiahnete systémovú zálohu pred pokračovaním, a potom nahrajte tento súbor po instalácii novej verzie.', UPGRADE_IMPORTANT_MESSAGES_2: 'Aktualizujete sa na novú hlavnú verziu. Uistite sa, že ste prečítali ChangeLog pre akékoľvek dôležité zmeny.', WARNING_SYSTEM_BACKUP: 'Toto vytvorí zálohu všetkých vašich celých systémových konfigurácií a nastavení. Všetky hesla budú čitateľné v zálohovom súbore. Buďte opatrní pri zdieľaní! Chcete pokračovať?' diff --git a/interface/src/i18n/sv/index.ts b/interface/src/i18n/sv/index.ts index c980a54fd..032eeb026 100644 --- a/interface/src/i18n/sv/index.ts +++ b/interface/src/i18n/sv/index.ts @@ -350,7 +350,7 @@ const sv: Translation = { NO_DATA_1: 'Inga favorit EMS enheter hittade än. Använd', NO_DATA_2: 'modul för att markera dem.', NO_DATA_3: 'För att se alla tillgängliga enheter, gå till', - NO_GPIO:'Inga tillgängliga GPIO-portar hittades', + NO_GPIO: 'Inga tillgängliga GPIO-portar hittades', THIS_VERSION: 'Denna version', PLATFORM: 'Plattform', RELEASE_TYPE: 'Utgivelsestyp', @@ -362,7 +362,7 @@ const sv: Translation = { STORED_VERSIONS: 'Lagrad versioner', ONLINE_HELP: 'online hjälp', UPGRADE_IMPORTANT_MESSAGES: 'Uppdatera viktiga meddelanden', - UPGRADE_IMPORTANT_MESSAGES_1: 'Denna uppdatering kräver en fabriksåterställning. Se till att du har gjort en säkerhetskopia av din konfiguration och inställningar innan du fortsätter och ladda upp denna efter att den nya versionen är installerad.', + UPGRADE_IMPORTANT_MESSAGES_1: 'Denna uppdatering kräver en fabriksåterställning. Se till att du först laddar ned en System Backup innan du fortsätter, och ladda upp denna fil efter att den nya versionen är installerad.', UPGRADE_IMPORTANT_MESSAGES_2: 'Du uppdaterar till en ny huvudversion. Se till att du har läst ChangeLog för eventuella brkande ändringar.', WARNING_SYSTEM_BACKUP: 'Detta kommer att skapa en säkerhetskopia av din fullständiga systemkonfiguration och inställningar. Alla lösenord kommer att vara läsbara i säkerhetskopien. Var försiktig med att dela! Vill du fortsätta?' diff --git a/interface/src/i18n/tr/index.ts b/interface/src/i18n/tr/index.ts index 154115d6a..b6caa3238 100644 --- a/interface/src/i18n/tr/index.ts +++ b/interface/src/i18n/tr/index.ts @@ -350,7 +350,7 @@ const tr: Translation = { NO_DATA_1: 'Henüz bir favori EMS varlığı bulunamadı. Kullanın', NO_DATA_2: 'modülünü kullanın.', NO_DATA_3: 'Tüm kullanılabilir varlıkları görmek için git', - NO_GPIO:'Kullanılabilir GPIO bulunamadı', + NO_GPIO: 'Kullanılabilir GPIO bulunamadı', THIS_VERSION: 'Bu Sürüm', PLATFORM: 'Platforma', RELEASE_TYPE: 'Sürüm Tipi', diff --git a/src/core/system.cpp b/src/core/system.cpp index 8fd36a633..6478465b2 100644 --- a/src/core/system.cpp +++ b/src/core/system.cpp @@ -288,11 +288,11 @@ void System::get_partition_info() { partition_info_.clear(); // clear existing data #ifdef EMSESP_STANDALONE - // dummy data for standalone mode - version, size, install_date - partition_info_["app0"] = {EMSESP_APP_VERSION, 0, ""}; - partition_info_["app1"] = {"", 0, ""}; - partition_info_["factory"] = {"", 0, ""}; - partition_info_["boot"] = {"", 0, ""}; + // dummy data for standalone mode - version, size, install_date in UTC epoch + partition_info_["app0"] = {EMSESP_APP_VERSION, 0, 0}; + partition_info_["app1"] = {"", 0, 0}; + partition_info_["factory"] = {"", 0, 0}; + partition_info_["boot"] = {"", 0, 0}; #else auto current_partition = (const char *)esp_ota_get_running_partition()->label; @@ -332,10 +332,8 @@ void System::get_partition_info() { p_info.version = EMSESP::nvs_.getString(part->label, "").c_str(); char c[20]; snprintf(c, sizeof(c), "d_%s", (const char *)part->label); - time_t d = EMSESP::nvs_.getULong(c, 0); - char time_string[25]; - strftime(time_string, sizeof(time_string), "%FT%T", localtime(&d)); - p_info.install_date = d > 1500000000L ? time_string : ""; + time_t d = EMSESP::nvs_.getULong(c, 0); + p_info.install_date = d > 1500000000L ? d : 0; // store UTC epoch; formatted to local time at render if (!p_info.version.empty()) { esp_image_metadata_t meta = {}; @@ -355,7 +353,7 @@ void System::get_partition_info() { #endif } -// set NTP install time/date for the current partition +// set install time/date for the current partition, in UTC // assumes NTP is connected and working void System::set_partition_install_date() { #ifndef EMSESP_STANDALONE @@ -1240,11 +1238,18 @@ void System::show_system(uuid::console::Shell & shell) { if (partition.second.version.empty()) { continue; // no version, empty string } + std::string installed; + if (partition.second.install_date > 0) { + char time_string[25]; + time_t d = partition.second.install_date; + strftime(time_string, sizeof(time_string), "%FT%T", localtime(&d)); + installed = std::string(", installed on ") + time_string; + } shell.printfln(" %s: v%s (%d KB%s) %s", partition.first.c_str(), partition.second.version.c_str(), partition.second.size, - partition.second.install_date.empty() ? "" : (std::string(", installed on ") + partition.second.install_date).c_str(), + installed.c_str(), (strcmp(esp_ota_get_running_partition()->label, partition.first.c_str()) == 0) ? "** active **" : ""); } diff --git a/src/core/system.h b/src/core/system.h index d05645a37..b3ee3c242 100644 --- a/src/core/system.h +++ b/src/core/system.h @@ -83,7 +83,7 @@ enum FUSE_VALUE : uint8_t { ALL = 0, MFG = 1, MODEL = 2, BOARD = 3, REV = 4, BAT struct PartitionInfo { std::string version; size_t size; - std::string install_date; // optional, only available if NTP is connected + time_t install_date; // UTC epoch seconds; 0 if unknown. Format with localtime() at render time so it honors the current TZ. }; class System { diff --git a/src/web/WebStatusService.cpp b/src/web/WebStatusService.cpp index f360ff99e..aa66292b1 100644 --- a/src/web/WebStatusService.cpp +++ b/src/web/WebStatusService.cpp @@ -146,18 +146,27 @@ void WebStatusService::systemStatus(AsyncWebServerRequest * request) { } // get the partition info for each partition, including the running one - // the partition data is done once in System::start() and stored in partition_info_ + // the partition data is gathered once in System::start() and stored in partition_info_ + // install_date is stored as a UTC epoch and formatted to local time here so it honors + // the current TZ (which may not have been set yet when System::start() ran). JsonArray partitions = root["partitions"].to(); for (const auto & partition : EMSESP::system_.partition_info_) { // Skip partition if it has no version, or it's size is 0 if (partition.second.version.empty() || partition.second.size == 0) { continue; } - JsonObject part = partitions.add(); - part["partition"] = partition.first; - part["version"] = partition.second.version; - part["size"] = partition.second.size; - part["install_date"] = partition.second.install_date; + JsonObject part = partitions.add(); + part["partition"] = partition.first; + part["version"] = partition.second.version; + part["size"] = partition.second.size; + if (partition.second.install_date > 0) { + char time_string[25]; + time_t d = partition.second.install_date; + strftime(time_string, sizeof(time_string), "%FT%T", localtime(&d)); + part["install_date"] = time_string; + } else { + part["install_date"] = ""; + } } root["developer_mode"] = EMSESP::system_.developer_mode();