X-Git-Url: https://plomlompom.com/repos/berlin_corona.txt?a=blobdiff_plain;f=plomtask%2Fdays.py;h=d64b34b6bc69c01fd6d6a17437bbc90f357d301a;hb=9e32ae00d4435932d55695be4e757ff109c76f26;hp=f1920b4d1343bbb486cd537b2c77102e22756a37;hpb=a8ee9d57c7ec297ef93d616141ac8970869fb6ef;p=plomtask diff --git a/plomtask/days.py b/plomtask/days.py index f1920b4..d64b34b 100644 --- a/plomtask/days.py +++ b/plomtask/days.py @@ -25,9 +25,11 @@ class Day: if not self.datetime: raise HandledException(f'Given date of wrong format: {self.date}') - def save(self, db_conn: DatabaseConnection): - """Add (or re-write) self to database.""" - db_conn.exec('REPLACE INTO days VALUES (?)', (self.date,)) + def __eq__(self, other: object): + return isinstance(other, self.__class__) and self.date == other.date + + def __lt__(self, other): + return self.date < other.date @classmethod def from_table_row(cls, row: Row): @@ -59,8 +61,6 @@ class Day: """Return what weekday matches self.date.""" return self.datetime.strftime('%A') - def __eq__(self, other: object): - return isinstance(other, self.__class__) and self.date == other.date - - def __lt__(self, other): - return self.date < other.date + def save(self, db_conn: DatabaseConnection): + """Add (or re-write) self to database.""" + db_conn.exec('REPLACE INTO days VALUES (?)', (self.date,))