Skip to content

Instantly share code, notes, and snippets.

@3isenHeiM
Created May 1, 2022 20:59
Show Gist options
  • Save 3isenHeiM/5c87bb1f35c8fdb63d43a314243d1104 to your computer and use it in GitHub Desktop.
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
#!/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