From: Christian Heller Date: Sat, 16 Mar 2024 23:24:38 +0000 (+0100) Subject: Add previously forgotten days module file, oops. X-Git-Url: https://plomlompom.com/repos/?a=commitdiff_plain;h=ee7279c0884262d5b329033cf77260fd850a5b91;hp=0b9590b2c15c246782d9a81e1df24baa73a09765;p=plomtask Add previously forgotten days module file, oops. --- 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