Skip to content

Commit

Permalink
Add calendar rules for Independence Day (don't observe 2009, for some…
Browse files Browse the repository at this point in the history
… reason
  • Loading branch information
Andrew Kirkegaard committed Feb 28, 2019
1 parent 18079b7 commit 1497853
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
21 changes: 17 additions & 4 deletions mpr/data/report_calendar.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,35 @@ def date_diff(first: Iterator[date], second: Iterator[date]) -> Set[date]:
return set(second) - set(first)


USIndependenceDayBefore2009 = Holiday('US Independence Day',
month=7,
day=4,
end_date='2009-07-01',
observance=nearest_workday)

USIndependenceDayAfter2009 = Holiday('US Independence Day',
month=7,
day=4,
start_date='2010-07-01',
observance=nearest_workday)

NewYearsDay = Holiday('New Years Day', month=1, day=1, observance=nearest_workday)
USIndependenceDay = Holiday('US Independence Day', month=7, day=4, observance=nearest_workday)
ChristmasEve = Holiday('Christmas Eve', month=12, day=24)
Christmas = Holiday('Christmas', month=12, day=25, observance=nearest_workday)

MartinLutherKingDay2013 = date(2013, 1, 21)
PresidentsDay2013 = date(2013, 2, 18)
GovernmentShutdown2013 = date_range(date(2013, 10, 1), date(2013, 10, 17))

report_calendar = AbstractHolidayCalendar(rules=[
NewYearsDay,
USMemorialDay,
USIndependenceDay,
USIndependenceDayBefore2009,
USIndependenceDayAfter2009,
USLaborDay,
USThanksgivingDay,
# ChristmasEve,
# Christmas
ChristmasEve,
Christmas
])

report_date = CustomBusinessDay(normalize=True, calendar=report_calendar, holidays=[
Expand Down
2 changes: 1 addition & 1 deletion test/reports/test_date_range.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def parse_date(element: Attributes) -> date:
calendar_dates = report_date_range(date(2001, 8, 6), date(2019, 2, 21))
report_dates = map(parse_date, report_dates)

# print('\n'.join(map(date.isoformat, sorted(date_diff(calendar_dates, report_dates)))))
print('\n'.join(map(date.isoformat, sorted(date_diff(report_dates, calendar_dates)))))


class DateRangeTest(TestCase):
Expand Down

0 comments on commit 1497853

Please sign in to comment.