Skip to content

Instantly share code, notes, and snippets.

@MatheusFaria
Created March 2, 2017 23:34
Show Gist options
  • Save MatheusFaria/cbf632bb1153b6a5b8be1033df9df4d2 to your computer and use it in GitHub Desktop.
Save MatheusFaria/cbf632bb1153b6a5b8be1033df9df4d2 to your computer and use it in GitHub Desktop.
Generate the days given a start, an end, and the weekdays that should be considered
from datetime import timedelta
from datetime import date
one_day = timedelta(days=1)
today = date.today()
start_day = date(today.year, 3, 6)
end_day = date(today.year, 7, 17)
# Moday is 0 - Sunday is 6
# valid_days = [0, 1, 2, 3, 4, 5, 6]
valid_days = [2, 4]
date_format = "%d/%m"
day = start_day
while day != end_day + one_day:
if day.weekday() in valid_days:
print(day.strftime(date_format))
day += one_day
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment