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