From ef1e916b8a5d836897d9b9f10d4f73347b248916 Mon Sep 17 00:00:00 2001 From: Rolf Amfelt Date: Sun, 14 Apr 2024 16:29:36 +0200 Subject: [PATCH] Calculate dates for at year --- datoer.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 datoer.py diff --git a/datoer.py b/datoer.py new file mode 100644 index 0000000..2f2ac8e --- /dev/null +++ b/datoer.py @@ -0,0 +1,13 @@ +import sys +import calendar + +year = 2024 +if len(sys.argv) > 1: + try: + year = int(sys.argv[-1]) + except ValueError: + pass + +for month in range(1, 13): + last_sunday = max(week[-1] for week in calendar.monthcalendar(year, month)) + print('{}-{}-{:2}'.format(year, calendar.month_abbr[month], last_sunday)) \ No newline at end of file