From ef4dfff9ff3002c11ccfef4190999a5e4e513606 Mon Sep 17 00:00:00 2001
From: Christian Heller <c.heller@plomlompom.de>
Date: Fri, 21 Jun 2024 18:26:04 +0200
Subject: [PATCH] Avoid confusing Day.by_id_or_create by always translating
 dating string first, so a look-up for "today" or so does not ignore the date
 equivalents.

---
 plomtask/days.py | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/plomtask/days.py b/plomtask/days.py
index 92e44b2..7e6a5cc 100644
--- a/plomtask/days.py
+++ b/plomtask/days.py
@@ -34,6 +34,13 @@ class Day(BaseModel[str]):
         day.todos = Todo.by_date(db_conn, day.id_)
         return day
 
+    @classmethod
+    def by_id_or_create(cls, db_conn: DatabaseConnection, id_: str | None
+                        ) -> Day:
+        """Extend BaseModel.by_id to ensure date name translation."""
+        assert isinstance(id_, str)
+        return super().by_id_or_create(db_conn, valid_date(id_))
+
     @classmethod
     def by_id(cls, db_conn: DatabaseConnection, id_: str) -> Day:
         """Extend BaseModel.by_id checking for new/lost .todos."""
-- 
2.30.2