diff --git a/apps/predbat/tests/test_web_functions.py b/apps/predbat/tests/test_web_functions.py index daf52ef57..7a7fd7753 100644 --- a/apps/predbat/tests/test_web_functions.py +++ b/apps/predbat/tests/test_web_functions.py @@ -155,6 +155,23 @@ def set_exporting(on): my_predbat.dashboard_index = original_dashboard_index + # ------------------------------------------------------------------------- + # Last Started/Last Updated date format consistency (issue #4223) + print("Test: Last Started date is displayed in the same format as Last Updated") + status_entity = prefix + ".status" + last_started_entity = prefix + ".last_started" + set_entity(my_predbat, status_entity, state="Idle", last_updated="2026-07-10 14:40:10.512590") + set_entity(my_predbat, last_started_entity, state="2026-07-10T01:10:39+0100") + my_predbat.dashboard_index = [status_entity] + status_html = web.get_status_html("1.0") + my_predbat.dashboard_index = original_dashboard_index + if "2026-07-10 01:10:39" not in status_html: + print(f" ERROR: expected 'Last Started' to be reformatted without 'T'/timezone offset, got: {status_html}") + failed += 1 + if "2026-07-10T01:10:39+0100" in status_html: + print(f" ERROR: 'Last Started' should not show the raw stored ISO format, got: {status_html}") + failed += 1 + # ------------------------------------------------------------------------- # Currency unit display in the web config pages (issue #4071) # The web UI must show the user's configured currency symbol, not the raw "p". diff --git a/apps/predbat/web.py b/apps/predbat/web.py index 073d9ac0f..6e88c2d02 100644 --- a/apps/predbat/web.py +++ b/apps/predbat/web.py @@ -582,6 +582,11 @@ def get_status_html(self, version): text += "Status{}\n".format(debug_title, status_full) text += "Last Updated{}\n".format(last_updated) last_started = self.get_state_wrapper(self.prefix + ".last_started", default=None) + if last_started: + try: + last_started = str2time(last_started).replace(tzinfo=None) + except (ValueError, TypeError) as e: + self.log("Warn: Failed to parse last_started time {}: {}".format(last_started, e)) text += "Last Started{}\n".format(last_started) text += "Version{}\n".format(version)