Skip to content

Commit

Permalink
Updated holiday date check to reset after a Sunday is reached
Browse files Browse the repository at this point in the history
  • Loading branch information
bbqandgames authored and 5ila5 committed Nov 28, 2024
1 parent 22ee1c9 commit 74e412a
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,9 @@ def fetch(self):
i += 1

# Cycle through schedule and holidays incorporating delays
# According to Republic Waste "Holidays typically push our residential pickup
# schedules back one day with regular schedules resuming the following week."
# Source: https://www.republicservices.com/customer-support/faq
while True:
changes = 0
for holiday in holidays:
Expand All @@ -126,8 +129,10 @@ def fetch(self):
d = holidays[holiday]["delay"]
for pickup in schedule:
p = schedule[pickup]["date"]
date_difference = (p - h).days
if date_difference <= 5 and date_difference >= 0:
# Calculate the next Sunday since Sunday should reset the
# scheduled pickup date
ns = h + timedelta(days=6 - h.weekday())
if h <= p < ns:
revised_date = p + timedelta(days=d)
schedule[pickup]["date"] = revised_date
holidays[holiday]["incorporated"] = True
Expand Down

0 comments on commit 74e412a

Please sign in to comment.