Skip to content

Instantly share code, notes, and snippets.

@pthrasher
Created December 12, 2014 15:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save pthrasher/d9c587c7546c313e6bf7 to your computer and use it in GitHub Desktop.
Save pthrasher/d9c587c7546c313e6bf7 to your computer and use it in GitHub Desktop.
Usage: python fridays_of.py <date> <num days to count back>
# Find all friday the 13th's of the last 1000 days
# python fridays_of.py 13 1000
import datetime
import sys
one_day = datetime.timedelta(days=1)
def is_fri(dt):
return dt.weekday() == 4
today = datetime.date.today()
if __name__ == '__main__':
date = int(sys.argv[1])
days_back = int(sys.argv[2])
for i in range(days_back):
if today.day is date and is_fri(today):
print today
today -= one_day
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment