home · contact · privacy
Add single-day view / retrieval.
[plomtask] / plomtask / days.py
index 3abd76974107d379813a888a8f6f39b7c44afdc8..f1920b4d1343bbb486cd537b2c77102e22756a37 100644 (file)
@@ -47,6 +47,13 @@ class Day:
         days.sort()
         return days
 
+    @classmethod
+    def by_date(cls, db_conn: DatabaseConnection, date: str):
+        """Retrieve Day by date if in DB, else return None."""
+        for row in db_conn.exec('SELECT * FROM days WHERE date = ?', (date,)):
+            return cls.from_table_row(row)
+        return None
+
     @property
     def weekday(self):
         """Return what weekday matches self.date."""