DRY up some code
This commit is contained in:
parent
77eec9cc84
commit
eac37d8843
5 changed files with 52 additions and 88 deletions
|
|
@ -109,14 +109,6 @@ class HistoryDialog(QDialog):
|
|||
self._load_versions()
|
||||
|
||||
# --- Data/UX helpers ---
|
||||
def _fmt_local(self, iso_utc: str) -> str:
|
||||
"""
|
||||
Convert UTC in the database to user's local tz
|
||||
"""
|
||||
dt = datetime.fromisoformat(iso_utc.replace("Z", "+00:00"))
|
||||
local = dt.astimezone()
|
||||
return local.strftime("%Y-%m-%d %H:%M:%S %Z")
|
||||
|
||||
def _load_versions(self):
|
||||
# [{id,version_no,created_at,note,is_current}]
|
||||
self._versions = self._db.list_versions(self._date)
|
||||
|
|
@ -126,7 +118,11 @@ class HistoryDialog(QDialog):
|
|||
)
|
||||
self.list.clear()
|
||||
for v in self._versions:
|
||||
label = f"v{v['version_no']} — {self._fmt_local(v['created_at'])}"
|
||||
created_at = datetime.fromisoformat(
|
||||
v["created_at"].replace("Z", "+00:00")
|
||||
).astimezone()
|
||||
created_at_local = created_at.strftime("%Y-%m-%d %H:%M:%S %Z")
|
||||
label = f"v{v['version_no']} — {created_at_local}"
|
||||
if v.get("note"):
|
||||
label += f" · {v['note']}"
|
||||
if v["is_current"]:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue