Created
May 1, 2022 20:59
-
-
Save 3isenHeiM/5c87bb1f35c8fdb63d43a314243d1104 to your computer and use it in GitHub Desktop.
Ce script python permet de lister les 10 prochaines dates de Simpélourd
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/env python3 | |
import calendar | |
import locale | |
from datetime import datetime, timedelta | |
locale.setlocale(locale.LC_TIME, 'fr_FR.UTF-8') ## first I set locale | |
c = calendar.Calendar(firstweekday=calendar.MONDAY) | |
# Get the 10 coming years | |
print("Voici le dates des futures Simpélourd :") | |
for year in range(2022,2032): | |
month = 10 | |
monthcal = c.monthdatescalendar(year, month) | |
try: | |
# Find the 3rd Sunday of October | |
third_sunday = [day for week in monthcal for day in week if | |
day.weekday() == calendar.SUNDAY and day.month == month][2] | |
# Get the day before | |
simpel_day = third_sunday - timedelta(days=1) | |
print(simpel_day.strftime("- %A %d %B %Y")) | |
except IndexError: | |
print('No date found') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment