/* Convert DD-MM-YY or DD-MM-YYYY to DD-MM-YYYY */
function roofbox_normalise_range_date($raw) {
    $parts = preg_split('/[-\/\.]/', trim($raw));
    if (count($parts) !== 3) return null;

    list($day, $month, $year) = $parts;

    if (strlen($year) === 2) {
        $year = "20" . $year;
    }

    $day = str_pad($day, 2, "0", STR_PAD_LEFT);
    $month = str_pad($month, 2, "0", STR_PAD_LEFT);

    return "$day-$month-$year";
}

/* Expand stored ranges into YYYY-MM-DD list */
function roofbox_expand_ranges_to_dates($ranges) {
    $dates = [];

    foreach ($ranges as $range) {
        $range = trim($range);
        if ($range === '') continue;

        if (strpos($range, 'to') !== false) {
            list($startRaw, $endRaw) = array_map('trim', explode('to', $range));

            $startNorm = roofbox_normalise_range_date($startRaw);
            $endNorm   = roofbox_normalise_range_date($endRaw);

            if (!$startNorm || !$endNorm) continue;

            // DD-MM-YYYY → YYYY-MM-DD
            list($dS, $mS, $yS) = explode('-', $startNorm);
            list($dE, $mE, $yE) = explode('-', $endNorm);

            $start = "$yS-$mS-$dS";
            $end   = "$yE-$mE-$dE";

            $current = $start;
            while ($current <= $end) {
                $dates[] = $current;
                $current = date('Y-m-d', strtotime($current . ' +1 day'));
            }
        } else {
            $singleNorm = roofbox_normalise_range_date($range);
            if ($singleNorm) {
                list($d, $m, $y) = explode('-', $singleNorm);
                $dates[] = "$y-$m-$d";
            }
        }
    }

    return $dates;
}
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="https://worcestershireroofboxhire.com/wp-sitemap-index.xsl" ?>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"><sitemap><loc>https://worcestershireroofboxhire.com/wp-sitemap-posts-post-1.xml</loc></sitemap><sitemap><loc>https://worcestershireroofboxhire.com/wp-sitemap-posts-page-1.xml</loc></sitemap><sitemap><loc>https://worcestershireroofboxhire.com/wp-sitemap-taxonomies-category-1.xml</loc></sitemap><sitemap><loc>https://worcestershireroofboxhire.com/wp-sitemap-users-1.xml</loc></sitemap></sitemapindex>
