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

RRULE UNTIL Property Should Be Inclusive #320

Closed
ge1157 opened this issue Oct 4, 2017 · 3 comments
Closed

RRULE UNTIL Property Should Be Inclusive #320

ge1157 opened this issue Oct 4, 2017 · 3 comments

Comments

@ge1157
Copy link

ge1157 commented Oct 4, 2017

In the case below the getOccurences() method is not returning the last day of the repeated event.

        [TestMethod]
        public void FiveDayRRule()
        {
            const string icalText = @"BEGIN:VCALENDAR
BEGIN:VEVENT
DTSTART;VALUE=DATE:20180101
DTEND;VALUE=DATE:20180107
RRULE:FREQ=WEEKLY;UNTIL=20180105;BYDAY=MO,TU,WE,TH,FR
DTSTAMP:20170926T001103Z
UID:5kvks79u4nurqopt7qv4fi1jo8@google.com
CREATED:20170922T131958Z
DESCRIPTION:
LAST-MODIFIED:20170922T131958Z
LOCATION:
SEQUENCE:0
STATUS:CONFIRMED
SUMMARY:Holiday Break - No School
TRANSP:TRANSPARENT
END:VEVENT
END:VCALENDAR
";
            const string timeZoneId = @"Eastern Standard Time";
            CalendarCollection collection = Calendar.LoadFromStream(new StringReader(icalText));
            var firstEvent = collection.First().Events.First();
            var startSearch = new CalDateTime(DateTime.Parse("2017-07-01T00:00:00"), timeZoneId);
            var endSearch = new CalDateTime(DateTime.Parse("2018-07-01T00:00:00"), timeZoneId);

            var occurrences = firstEvent.GetOccurrences(startSearch, endSearch)
                .Select(o => o.Period as Period)
                .OrderBy(p => p.StartTime)
                .ToList();

            Console.WriteLine("FiveDayRRule() found {0} occurences.", occurrences.Count());
            Assert.IsTrue(occurrences.Count() == 5);
        }
@rianjs
Copy link
Collaborator

rianjs commented Oct 4, 2017

Your DTEND makes no sense. You’ve specified a 7 day long event that repeats daily for five days.

@ge1157
Copy link
Author

ge1157 commented Oct 4, 2017

My apologies for the offending DTEND. Following is the code using the original VEVENT snippet:

[TestMethod]
        public void FiveDayRRule()
        {
            const string icalText = @"BEGIN:VCALENDAR
BEGIN:VEVENT
DTSTART;VALUE=DATE:20180101
DTEND;VALUE=DATE:20180102
RRULE:FREQ=WEEKLY;UNTIL=20180105;BYDAY=MO,TU,WE,TH,FR
DTSTAMP:20170926T001103Z
UID:5kvks79u4nurqopt7qv4fi1jo8@google.com
CREATED:20170922T131958Z
DESCRIPTION:
LAST-MODIFIED:20170922T131958Z
LOCATION:
SEQUENCE:0
STATUS:CONFIRMED
SUMMARY:Holiday Break - No School
TRANSP:TRANSPARENT
END:VEVENT
END:VCALENDAR
";
            const string timeZoneId = @"Eastern Standard Time";
            CalendarCollection collection = Calendar.LoadFromStream(new StringReader(icalText));
            var firstEvent = collection.First().Events.First();
            var startSearch = new CalDateTime(DateTime.Parse("2017-07-01T00:00:00"), timeZoneId);
            var endSearch = new CalDateTime(DateTime.Parse("2018-07-01T00:00:00"), timeZoneId);

            var occurrences = firstEvent.GetOccurrences(startSearch, endSearch)
                .Select(o => o.Period as Period)
                .OrderBy(p => p.StartTime)
                .ToList();

            Console.WriteLine("FiveDayRRule() found {0} occurences.", occurrences.Count());
            foreach (var entry in occurrences)
            {
                Console.WriteLine("{0} to {1}", entry.StartTime, entry.EndTime);
            }
            Assert.IsTrue(occurrences.Count() == 5);
        }

It only produces 4 occurrences. Using Ical.Net v3.0.12 obtained in VS2013 using NuGet.

rianjs pushed a commit that referenced this issue Nov 9, 2017
…RULE match the time zone of the DTSTART property. UNTIL should also be inclusive. Fixed a unit test that asserted the wrong values, and eliminated the coercion to UTC when evaluating UNTIL-based RRULEs. #320
@rianjs
Copy link
Collaborator

rianjs commented Nov 13, 2017

Fixed in nuget version 4.0.0: https://www.nuget.org/packages/Ical.Net/4.0.0

@rianjs rianjs closed this as completed Nov 13, 2017
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

2 participants