From c8dc9f5c9899042c0851a9c7225e350bc4598000 Mon Sep 17 00:00:00 2001 From: Joshua Westgard Date: Wed, 9 Dec 2015 17:43:35 -0500 Subject: [PATCH] create schedule.py for planning 2016 --- schedule.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100755 schedule.py diff --git a/schedule.py b/schedule.py new file mode 100755 index 0000000..3a5cae6 --- /dev/null +++ b/schedule.py @@ -0,0 +1,29 @@ +#!/usr/bin/env python3 +from datetime import date, timedelta +import holidays + +ch = holidays.UnitedStates() +ch.update({ "2016-02-07": "Super Bowl Sunday", "2016-02-14": "Valentine's Day", + "2016-03-27": "Easter Sunday", "2016-05-08": "Mother's Day", + "2016-06-19": "Father's Day", "2016-07-03": "4th of July Weekend", + "2016-10-02": "Rosh Hashanah (begins at sundown)", "2016-11-27": + "Thanksgiving Weekend"}) + +def secondsundays(d): + while d.year == 2016: + yield d + d += timedelta(days = 14) + +start1 = date(2016, 1, 3) +start2 = date(2016, 1, 10) +schedule1 = [d.strftime('%Y-%m-%d') for d in secondsundays(start1)] +schedule2 = [d.strftime('%Y-%m-%d') for d in secondsundays(start2)] + +for s in (schedule1, schedule2): + heading = "\nStart on {0}".format(s[0]) + print("\n".join([heading, "=" * (len(heading)-1)])) + for d in s: + if d in ch: + print(d, ch.get(d)) + else: + print(d)