Skip to content

Instantly share code, notes, and snippets.

@travishathaway
Created October 9, 2025 06:27
Show Gist options
  • Select an option

  • Save travishathaway/069b52d5a76a25ea6d8fdfbc0416d833 to your computer and use it in GitHub Desktop.

Select an option

Save travishathaway/069b52d5a76a25ea6d8fdfbc0416d833 to your computer and use it in GitHub Desktop.
Days Off Calculator
"""
I wrote this script because I'm trying to figure out what day
would be the best day to take off if I only want to work four days
a week.
The best day here means I will get the most time off in the year if
I choose this day.
The holidays are German holidays and the extra days are company
holidays.
"""
from copy import copy
from collections import Counter
from datetime import date, UTC, timedelta
from pprint import pprint
HOLIDAYS = {
date(2026, 1, 1),
date(2026, 2, 13),
date(2026, 8, 3),
date(2026, 4, 3),
date(2026, 4, 6),
date(2026, 5, 1),
date(2026, 5, 14),
date(2026, 5, 22),
date(2026, 5, 25),
date(2026, 7, 6),
date(2026, 10, 3),
date(2026, 10, 16),
date(2026, 12, 25),
date(2026, 12, 26),
}
WEEKEND = {"Sat", "Sun"}
def main():
days_off_counter = Counter()
days_off = {
"Mon",
"Tue",
"Wed",
"Thu",
"Fri",
}
for day in days_off:
start_day = date(2026, 1, 1)
current_day = copy(start_day)
while current_day.year < start_day.year + 1:
current_day_of_week = current_day.strftime("%a")
if current_day in HOLIDAYS and current_day not in WEEKEND:
days_off_counter[day] += 1
elif current_day_of_week == day:
days_off_counter[day] += 1
current_day += timedelta(days=1)
pprint(days_off_counter)
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment