X-Git-Url: https://plomlompom.com/repos/feed.xml?a=blobdiff_plain;f=days.py;fp=days.py;h=12328a6ed0927c5a2b970c4ef2318311156eaba7;hb=ee7279c0884262d5b329033cf77260fd850a5b91;hp=0000000000000000000000000000000000000000;hpb=0b9590b2c15c246782d9a81e1df24baa73a09765;p=plomtask diff --git a/days.py b/days.py new file mode 100644 index 0000000..12328a6 --- /dev/null +++ b/days.py @@ -0,0 +1,24 @@ +#!/usr/bin/env python3 +"""Collecting Day and date-related items.""" +from datetime import datetime + +DATE_FORMAT = '%Y-%m-%d' + + +class Day: + """Individual days defined by their dates.""" + + def __init__(self, date): + self.date = date + self.datetime = datetime.strptime(date, DATE_FORMAT) + + @property + def weekday(self): + """Return what weekday matches self.date.""" + return self.datetime.strftime('%A') + + def __eq__(self, other): + return self.date == other.date + + def __lt__(self, other): + return self.date < other.date