Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recurrence issue #371

Closed
nicuchiran opened this issue Mar 27, 2018 · 7 comments
Closed

Recurrence issue #371

nicuchiran opened this issue Mar 27, 2018 · 7 comments

Comments

@nicuchiran
Copy link

nicuchiran commented Mar 27, 2018

Hi,

I have the following situation:

  • I use a Kendo Scheduler to create events (into a database). Then I use the created events as work planning for employees.
  • I have an event created on 2018-03-19 (on a Monday), with a recurrence, "FREQ=WEEKLY;BYDAY=WE,TH,FR". The recurrence rule excludes the day when I created the event on, because it's not on WE, TH or FR. (It might look a bit stupid, but I have a situation from a customer).
  • The Kendo Scheduler displays the recurrent event correctly, on WE, TH and FR, so not on Monday 19th.
  • Then I use a Ical.Net.Calendar to inspect all the plannings, in order to have the recurrences reflected in the scheduled work too. I manually create the calendar and an event (which I add it to the calendar).
  • When I inspect the day of 19, I see that there is an occurrence, which I think is incorrect (as I already said, the reference rule is excluding Mondays).

My questions are:

  1. Do you find logic my situation?
  2. If yes, is it possible to implement a fix for it?

This is my test code:

        var calendar = new Ical.Net.Calendar();
        
        var ev = new Ical.Net.Event()
        {
            DtStart = new Ical.Net.DataTypes.CalDateTime(new DateTime(2018, 3, 19, 8, 30, 0)),
            DtEnd = new Ical.Net.DataTypes.CalDateTime(new DateTime(2018, 3, 19, 17, 0, 0)),
        };
        
        ev.RecurrenceRules.Add(new Ical.Net.DataTypes.RecurrencePattern("FREQ=WEEKLY;BYDAY=WE,TH,FR"));
        
        calendar.Events.Add(ev);

        var occurrences = calendar.GetOccurrences(new DateTime(2018, 3, 19));
        // According to my logic, occurrences should be empty: 2018-03-19 is not a WE, TH nor FR, according to the recurrence rule.

Thank you!

@rianjs
Copy link
Collaborator

rianjs commented Mar 27, 2018

Can you post the ical text that Kendo creates?

@nicuchiran
Copy link
Author

Hi,

Thanks for your quick reaction!

I didn't know exactly what do you mean by "ical text", but I found an example and I hope it's what do you need. If not, please advise!
So please find attached my file.
console.log

@rianjs
Copy link
Collaborator

rianjs commented Mar 27, 2018

Yeah, when Kendo serializes the event(s), it will produce something like this:

BEGIN: VCALENDAR
VERSION:4.0
PRODID: -//github.com/rianjs/ical.net//NONSGML ical.net 4.0//EN
BEGIN:VEVENT
DTEND:20160704T172520
DTSTAMP:20160704T162520
DTSTART:20160704T162520
RRULE:FREQ=DAILY;COUNT=5
SEQUENCE: 0
UID: f4693a88-0a57-4761-b949-8822b8a507d2
END:VEVENT
END:VCALENDAR

Can you paste the text that Kendo creates? I think you're saving them to the database?

@nicuchiran
Copy link
Author

Hi,

I used a script from here to export the events (https://docs.telerik.com/kendo-ui/controls/scheduling/scheduler/how-to/export/ical-export), but the format generated is slightly different than yours:

UID:0@default
CLASS:PUBLIC
DESCRIPTION: Normal work schedule
DTSTAMP;VALUE=DATE-TIME:20180328T102102
DTSTART;VALUE=DATE-TIME:20180320T083000
DTEND;VALUE=DATE-TIME:20180320T170000
LOCATION:
SUMMARY;LANGUAGE=en-us:8:30 - 17:00 Shift with 12:30 - 13:00 Break ( Normal work schedule)
TRANSP:TRANSPARENT
END:VEVENT

If I inspect the events inside the scheduler and put it in the format you provided, it would look like this:

VERSION:4.0
PRODID: -//github.com/rianjs/ical.net//NONSGML ical.net 4.0//EN
BEGIN:VEVENT
DTEND:VALUE=DATE-TIME:20180320T170000
DTSTAMP:VALUE=DATE-TIME:20180328T102102
DTSTART:VALUE=DATE-TIME:20180320T083000
RRULE:FREQ=WEEKLY;UNTIL=20180331T215959Z;BYDAY=WE,TH,FR
SEQUENCE:0
UID:ca25d651-fd20-4a4e-87f2-8bad0a71d6f8
END:VEVENT
END:VCALENDAR

Is this ok?

@minichma
Copy link
Collaborator

Unfortunately rfc 5545 leaves this case undefined:

The recurrence set generated with a "DTSTART" property value that doesn't match the pattern of the rule is undefined.

However, I agree, that one would intuitively expect, and that it makes a lot of sense, that dtstart itself isn't returned if it doesn't match the rrule. It also seems that most libs implement it that way. So +1 for implementing iCal.net that way too.

@nicuchiran
Copy link
Author

So, can we expect for this implementation?

@rianjs
Copy link
Collaborator

rianjs commented May 27, 2018

This is a Telerik idiosyncrasy that I worked around in one of our applications this week. Telerik hard-codes that all UNTIL values are UTC, which is bogus.

The workaround is to manually change each IAppointment’s RecurUntil value, and specify a DateTimeKind of Local using DateTime.SpecifyKind. That means you’ll need a filter all values coming from Telerik. There is no other way.

This is a Telerik bug. I disassembled the Telerik DLLs and found the specific methods that do the wrong thing(s). It’s very frustrating. I spent hours unwinding the problem, but it’s part of a larger problem with Telerik controls: they’re really bad at handling anything time zone-related.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants