osamc.de/dritter_mittwoch_im_monat.py

28 lines
900 B
Python
Raw Normal View History

2023-10-17 18:09:30 +02:00
#! /usr/bin/env python3
# -*- coding: utf-8 -*-
import calendar
import datetime
year = 2023
for year in range(datetime.datetime.now().year, datetime.datetime.now().year+3):
justDays = []
germanMonthAndDays = []
iso = []
print ("Every third Wednesday in a month (without December) for the year", year )
for month in range(1, 12):
c = 0
for day in range(1, 22): # 22th is the latest a wednesday can be in a month. if thursday is the 1st
if calendar.weekday(year, month, day) == calendar.WEDNESDAY:
c += 1
if c == 3:
justDays.append(f"{day}")
germanMonthAndDays.append(f"{day}.{month}.")
iso.append(f"{year}-{month}-{day}")
break
print (" ".join(justDays))
print (" ".join(germanMonthAndDays))
print (" ".join(iso))
print()