Calendar Week Starting with Sunday

    <dates name="calendar-month">
        <dateshift day="-6">
            <defdate weekday="SU" name="sunday-of-first-week"/>
        </dateshift>
        <dateshift to="sunday-of-first-week">
            <!-- generate 6 weeks of dates (6 * 7 = 42) -->
            <dategen freq="daily" count="42" />
        </dateshift>
        
        <!-- Shift back one day to get the last day of previous month and store it. -->
        <defdate day="-1" name="last-day-of-previous-month"/>
        <!-- Store the last generated date from the main sequence. -->
        <dateshift to="sunday-of-first-week">
            <defdate day="+41" name="last-generated-date"/>
        </dateshift>
        
        <!-- Mark all dates up to the last day of previous month for deletion. -->
        <dateshift to="sunday-of-first-week">
            <dategen freq="daily" until="last-day-of-previous-month" tag="out-of-range"/>
        </dateshift>
        <!-- Mark all dates from next month for deletion. -->
        <!-- We start with first day of main month again, then shift to first day of next month. -->
        <dateshift month="+1">
            <dategen freq="daily" until="last-generated-date" tag="out-of-range"/>
        </dateshift>
    </dates>

Last updated