Created
December 12, 2014 15:12
-
-
Save pthrasher/d9c587c7546c313e6bf7 to your computer and use it in GitHub Desktop.
Usage: python fridays_of.py <date> <num days to count back>
This file contains 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
# 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