home · contact · privacy
Add previously forgotten days module file, oops.
authorChristian Heller <c.heller@plomlompom.de>
Sat, 16 Mar 2024 23:24:38 +0000 (00:24 +0100)
committerChristian Heller <c.heller@plomlompom.de>
Sat, 16 Mar 2024 23:24:38 +0000 (00:24 +0100)
days.py [new file with mode: 0644]

diff --git a/days.py b/days.py
new file mode 100644 (file)
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