Most people treat PTO as a currency that they spend one day at a time. What if you could treat it like a lever?
This is the idea that sparked this project: the same Thursday off can be worth completely different amounts of time away from work, depending entirely on where it falls on the calendar.
Take a random Thursday in February - you'll have a day off. Nice.
Take for example Thursday, November 26, 2026: Thanksgiving. Now that Thursday comes preloaded with a Friday (most employers give it), Saturday, and Sunday. Suddenly, you're looking at a 4-day break without spending PTO. But if you also take Monday through Wednesday before, you will have spent 3 days of PTO and earned 9 consecutive days off. That's a 3x multiplier.
I became obsessed with this math. So I created Holiday Optimizer, a free tool that finds each of these opportunities for your country and year, and then determines the optimal combination based on your PTO budget.
The algorithm
The core idea is simple: holidays and weekends create “anchors” of free time throughout the year. The optimizer's job is to find the gaps between those anchors where a small number of PTO days can tie them together into much longer stretches.
Here's how it works, step by step:
Step 1: Load the holiday calendar
The tool requires three inputs: country, year, and how many days of PTO you have. It then loads all the holidays for that country/year using the date-holidays.
npm package, which is surprisingly comprehensive and covers hundreds of places, including German state holidays.
Step 2: Identify bridging opportunities
For each holiday, I look at the days surrounding it. The algorithm goes in both directions: if a holiday falls on a Tuesday, taking Monday off ties it to the weekend, turning 1 day of PTO into a 4-day break (Saturday, Sunday, Monday, and Tuesday). If two holidays are close together (for example, Christmas Day on Thursday and New Year's Day the following Thursday), the gap between them might require only 3 or 4 days of PTO to add up to almost 2 weeks of rest.
Each "cluster" (a contiguous block of free time) receives a score:
efficiency = consecutive_earned_days / used_pt_days
A 9-day break using 3 days of PTO earns a score of 3.0. A 4-day weekend with 1 day of PTO earns a score of 4.0. The algorithm favors high-efficiency clusters.
Step 3: Find the optimal non-overlapping combination
This is where it gets interesting. Once you have a scored list of potential groups, you'll need to find the best combination of non-overlapping groups that fits your PTO budget. This is structurally similar to the weighted interval programming problem: a classic DP setup.
I use a greedy approach with a twist: I sort groups by descending efficiency, then greedily select each one that doesn't overlap with already selected groups and doesn't exceed the remaining PTO budget. This is not always globally optimal for maximizing total days off, but it reliably produces the most efficient plan, which is usually what people really want. Pure PD to maximize total days would also work, but greedy for efficiency gives more intuitive results: you get the "best performance per day" combinations, not just the longest possible leg.
Step 4: Exit
The result is a ranked list of "PTO packages": concrete date ranges with the specific days off you should request, how many PTO days each one costs, and how many consecutive days off you'll get in return. It also shows what the full year looks like if you use your entire budget on top recommendations.
A real example from 2026 (USA)
Let me explain what this would look like for a US employee with 10 days of PTO in 2026.
Independence Day: July 4, 2026 (Saturday)
July 4 falls on a Saturday, so the federal observance moves to Friday, July 3. That means that most companies already give Friday off. Take Thursday, July 2 with 1 day of PTO