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

EXDATE master ticket: time zones, durations, etc. #259

Closed
rianjs opened this issue Apr 5, 2017 · 2 comments
Closed

EXDATE master ticket: time zones, durations, etc. #259

rianjs opened this issue Apr 5, 2017 · 2 comments

Comments

@rianjs
Copy link
Collaborator

rianjs commented Apr 5, 2017

This ticket combines part of #239 and all of #140.

EXDATEs fold improperly

If you add a second EXDATE to a collection, this is the output:

EXDATE;TZID=UTC:20170404T123000
EXDATE;TZID=UTC:20170403T123000

It should be:

EXDATE;TZID=UTC:20170404T123000,20170403T123000

Unit test:

[Test]
public void ExDateFold_Tests()
{
    var start = DateTime.Now.AddYears(-1);
    var end = start.AddHours(1);
    var rrule = new RecurrencePattern(FrequencyType.Daily) { Until = start.AddYears(2) };
    var e = new Event
    {
        DtStart = new CalDateTime(start),
        DtEnd = new CalDateTime(end),
        RecurrenceRules = new List<IRecurrencePattern> { rrule }
    };

    var firstExclusion = new CalDateTime(start.AddDays(4));
    e.ExceptionDates = new List<IPeriodList> { new PeriodList { new Period(firstExclusion) } };
    var serialized = SerializeToString(e);
    Assert.AreEqual(1, Regex.Matches(serialized, "EXDATE:").Count);

    var secondExclusion = new CalDateTime(start.AddDays(5));
    e.ExceptionDates.Add(new PeriodList { new Period(secondExclusion) });
    serialized = SerializeToString(e);
    Assert.AreEqual(1, Regex.Matches(serialized, "EXDATE:").Count);
}

Specifying a CalDateTime with a TzId should include the TzId as part of serialization ( #239 )

Unit test:

[Test]
public void ExDateTimeZone_Tests()
{
    const string tzid = "Europe/Stockholm";
    var later = _now.AddHours(1);

    //Repeat daily for 10 days
    var rrule = new RecurrencePattern(FrequencyType.Daily, 1) { Count = 10 };

    var e = new Event
    {
        DtStart = new CalDateTime(_now, tzid),
        DtEnd = new CalDateTime(later, tzid),
        RecurrenceRules = new List<IRecurrencePattern> { rrule },
    };

    var exceptionDateList = new PeriodList();
    exceptionDateList.TzId = tzid;
    exceptionDateList.Add(new Period(new CalDateTime(_now.AddDays(1), tzid)));
    e.ExceptionDates.Add(exceptionDateList);

    var serialized = SerializeToString(e);
    const string expected = "EXDATE;TZID=Europe/Stockholm:";
    Assert.AreEqual(1, Regex.Matches(serialized, expected).Count);
}
@rianjs
Copy link
Collaborator Author

rianjs commented Apr 6, 2017

So EXDATEs fold properly, and always did. I was creating new PeriodLists underneath (which is allowed). So that wasn't actually a bug. Oh well.

Part 2 is fixed.

@rianjs rianjs closed this as completed Apr 6, 2017
@rianjs rianjs reopened this Apr 7, 2017
@rianjs
Copy link
Collaborator Author

rianjs commented Apr 7, 2017

It might help if I connect de-serialization to the TZID, too.

rianjs pushed a commit that referenced this issue Apr 28, 2017
@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

1 participant