From ee7279c0884262d5b329033cf77260fd850a5b91 Mon Sep 17 00:00:00 2001 From: Christian Heller Date: Sun, 17 Mar 2024 00:24:38 +0100 Subject: [PATCH] Add previously forgotten days module file, oops. --- days.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 days.py 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 -- 2.30.2