What are the implications of potential leap years on date range splitting algorithms in PHP?

When dealing with date range splitting algorithms in PHP, potential leap years can pose a challenge as they consist of an additional day. To account for this, the algorithm should check if the year being processed is a leap year and adjust the date range splitting accordingly.

function splitDateRange($start, $end) {
    $startDate = new DateTime($start);
    $endDate = new DateTime($end);
    
    $interval = $endDate->diff($startDate);
    
    $leapYearDays = 0;
    for ($year = $startDate->format('Y'); $year <= $endDate->format('Y'); $year++) {
        if (date('L', strtotime("$year-01-01"))) {
            $leapYearDays++;
        }
    }
    
    $days = $interval->days + $leapYearDays;
    
    // Split the date range based on the adjusted number of days
    // Implement your logic here
    
    return $result;
}