Format snapshot timestamps as readable dates in snapshots browser
Display '2026-03-06 14:07:06' instead of raw '2026-03-06T140706'. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import re
|
||||
from datetime import datetime
|
||||
|
||||
from textual.app import ComposeResult
|
||||
from textual.screen import Screen
|
||||
@@ -11,6 +12,15 @@ from tui.backend import run_cli
|
||||
from tui.widgets import SnapshotBrowser
|
||||
|
||||
|
||||
def _format_snapshot_ts(ts: str) -> str:
|
||||
"""Format '2026-03-06T140706' as '2026-03-06 14:07:06'."""
|
||||
try:
|
||||
dt = datetime.strptime(ts, "%Y-%m-%dT%H%M%S")
|
||||
return dt.strftime("%Y-%m-%d %H:%M:%S")
|
||||
except ValueError:
|
||||
return ts
|
||||
|
||||
|
||||
class SnapshotsScreen(Screen):
|
||||
|
||||
BINDINGS = [("escape", "go_back", "Back")]
|
||||
@@ -74,7 +84,7 @@ class SnapshotsScreen(Screen):
|
||||
lines = [l.strip() for l in stdout.splitlines() if l.strip() and not l.startswith("===")]
|
||||
if lines:
|
||||
for s in lines:
|
||||
table.add_row(s, key=s)
|
||||
table.add_row(_format_snapshot_ts(s), key=s)
|
||||
else:
|
||||
self.notify("No snapshots found", severity="warning")
|
||||
if stderr:
|
||||
|
||||
Reference in New Issue
Block a user