A friend asked me to help her find the exact midpoint between her and her partner's birthdays — apparently it's a whole thing people do, so they get a "shared" anniversary to celebrate every year. I figured it'd be a five-minute (date1 + date2) / 2 kind of problem. It's not. Building the date calculator that eventually answered her question, I ran into a genuinely annoying edge case: sometimes there just isn't a single day exactly in the middle.

Counting days between two dates without native Date math

The tool doesn't do new Date(a) - new Date(b) and divide by 86400000. It uses Luxon, parses both inputs as calendar dates, and asks Luxon for a calendar-aware diff:

let start = DateTime.fromISO(twoDate.date1);

let end = DateTime.fromISO(twoDate.date2);