In this episode, we cover how to handle employee schedule exclusions—basically, how to subtract periods from an employee's regular working schedule, like for holidays or time off.
We start with a full, regular weekday schedule (e.g., 9-5, Monday to Friday), and then add an exclusion for a particular day off (like a holiday). You’ll see exactly how to set up such an exclusion in the database, specifying which employee and what time period to exclude. We do a quick demo to show that these exclusion periods are not yet being applied, and then jump into the code to iterate over exclusions and remove them from the regular schedule.
Next, we refactor the method for handling these exclusions. We demonstrate subtracting out not just full days, but also partial days (like taking just the morning off), to show you how flexible the system is. There’s a bit of trial and error as the code is tweaked to handle all-day exclusions, half-days, and even multi-day breaks (including when the schedule might normally skip weekends).
By the end, we’ve got a schedule where exclusions are correctly being subtracted—holidays, partial shifts, whatever you need. It’s a powerful way to accurately reflect an employee’s availability after accounting for time off or special exceptions.