Skip to content

Commit bf8f848

Browse files
authored
Make "Last Started" date format on dashboard match "Last Updated" (#4229)
* Initial plan * Fix Last Started date format on web dashboard to match Last Updated --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
1 parent e911d2c commit bf8f848

2 files changed

Lines changed: 22 additions & 0 deletions

File tree

apps/predbat/tests/test_web_functions.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,23 @@ def set_exporting(on):
155155

156156
my_predbat.dashboard_index = original_dashboard_index
157157

158+
# -------------------------------------------------------------------------
159+
# Last Started/Last Updated date format consistency (issue #4223)
160+
print("Test: Last Started date is displayed in the same format as Last Updated")
161+
status_entity = prefix + ".status"
162+
last_started_entity = prefix + ".last_started"
163+
set_entity(my_predbat, status_entity, state="Idle", last_updated="2026-07-10 14:40:10.512590")
164+
set_entity(my_predbat, last_started_entity, state="2026-07-10T01:10:39+0100")
165+
my_predbat.dashboard_index = [status_entity]
166+
status_html = web.get_status_html("1.0")
167+
my_predbat.dashboard_index = original_dashboard_index
168+
if "2026-07-10 01:10:39" not in status_html:
169+
print(f" ERROR: expected 'Last Started' to be reformatted without 'T'/timezone offset, got: {status_html}")
170+
failed += 1
171+
if "2026-07-10T01:10:39+0100" in status_html:
172+
print(f" ERROR: 'Last Started' should not show the raw stored ISO format, got: {status_html}")
173+
failed += 1
174+
158175
# -------------------------------------------------------------------------
159176
# Currency unit display in the web config pages (issue #4071)
160177
# The web UI must show the user's configured currency symbol, not the raw "p".

apps/predbat/web.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -582,6 +582,11 @@ def get_status_html(self, version):
582582
text += "<tr><td>Status</td><td{}>{}</td></tr>\n".format(debug_title, status_full)
583583
text += "<tr><td>Last Updated</td><td>{}</td></tr>\n".format(last_updated)
584584
last_started = self.get_state_wrapper(self.prefix + ".last_started", default=None)
585+
if last_started:
586+
try:
587+
last_started = str2time(last_started).replace(tzinfo=None)
588+
except (ValueError, TypeError) as e:
589+
self.log("Warn: Failed to parse last_started time {}: {}".format(last_started, e))
585590
text += "<tr><td>Last Started</td><td>{}</td></tr>\n".format(last_started)
586591
text += "<tr><td>Version</td><td>{}</td></tr>\n".format(version)
587592

0 commit comments

Comments
 (0)