- @classmethod
- def by_date(cls, db_conn: DatabaseConnection,
- date: str, create: bool = False) -> Day:
- """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)
- if not create:
- raise NotFoundException(f'Day not found for date: {date}')
- return cls(date)
+ @property
+ def date(self) -> str:
+ """Return self.id_ under the assumption it's a date string."""
+ assert isinstance(self.id_, str)
+ return self.id_
+
+ @property
+ def first_of_month(self) -> bool:
+ """Return what month self.date is part of."""
+ assert isinstance(self.id_, str)
+ return self.id_[-2:] == '01'
+
+ @property
+ def month_name(self) -> str:
+ """Return what month self.date is part of."""
+ return self.datetime.strftime('%B')