Search code examples
kendo-uiicalendarkendo-scheduler

Kendo UI scheduler - handle leap years


I am using Kendo UI scheduler to show my events and I have events that should be shown for each year on a specific date.

To achieve that, I use yearly reference rule and everything works fine until event's date is not 29th February. In that case my event get's pushed to the March 1st, even if current year has that date.

The only case in which my date doesn't get pushed to 1st March is if event's date is set to 29th February of the current year.

Is there any way to handle this as I didn't find any info regarding leap years in the Kendo UI documentation?


Solution

  • According to telerik, currently it can be done only by using more specific recurrence rule.

    For 29th February that would be: "FREQ=YEARLY;BYMONTH=2;BYMONTHDAY=29".

    My solution was to generate specific recurrence rule for each record by using following method:

    private string GenerateEventYearlyRecurrenceRule(DateTime eventStart)
    {
        return $"FREQ=YEARLY;BYMONTH={eventStart.Month};BYMONTHDAY={eventStart.Day}";
    }