home · contact · privacy
071b0b1b27d76b676d02ee4d4530563a5ba547b5
[plomtask] / plomtask / days.py
1 """Collecting Day and date-related items."""
2 from datetime import datetime
3
4 DATE_FORMAT = '%Y-%m-%d'
5
6
7 class Day:
8     """Individual days defined by their dates."""
9
10     def __init__(self, date: str):
11         self.date = date
12         self.datetime = datetime.strptime(date, DATE_FORMAT)
13
14     @property
15     def weekday(self):
16         """Return what weekday matches self.date."""
17         return self.datetime.strftime('%A')
18
19     def __eq__(self, other: object):
20         return isinstance(other, self.__class__) and self.date == other.date
21
22     def __lt__(self, other):
23         return self.date < other.date