The formulas
Buffer days must be fewer than the study window, otherwise the calculation would leave no study days at all.
Study days run from your start date up to, but not including, the exam date. Those days are split into weekdays (Monday to Friday) and weekend days (Saturday and Sunday).
plannedHours = (weekdayCount × weekdayHours) + (weekendCount × weekendHours). Buffer days are then removed at your own average rate: averageDailyHours = plannedHours ÷ studyDays, bufferHours = bufferDays × averageDailyHours, and effectiveHours = plannedHours − bufferHours, never below zero.
