Przeprowadziłem kilka testów. Tu jest mój kodu:Czy biblioteka DDay Ical prawidłowo oblicza powtarzające się reguły?
var systemTimeZone = TimeZoneInfo.FindSystemTimeZoneById("Pacific Standard Time");
var icalTimeZone = iCalTimeZone.FromSystemTimeZone(systemTimeZone);
var startTimeSearch = new DateTime(2015, 9, 8, 0, 0, 0, DateTimeKind.Utc);
var endTimeSearch = new DateTime(2015, 12, 1, 00, 0, 0, DateTimeKind.Utc);
var iCalendar = new iCalendar();
var pacificTimeZone = _iCalendar.AddTimeZone(icalTimeZone);
var event = new Event
{
Summary = "This is an event at 2015-09-08 10:30 PST (2015-09-08 17:30 UTC)",
DTStart = new iCalDateTime(2015, 9, 8, 10, 30, 0, pacificTimeZone.TZID, iCalendar),
Duration = new TimeSpan(0, 1, 0, 0)
};
var rp = new RecurrencePattern("FREQ=WEEKLY;UNTIL=20151112T080000Z;WKST=SU;BYDAY=TU");
event.RecurrenceRules.Add(rp);
iCalendar.Events.Add(_event);
var occurrences = iCalendar.GetOccurrences(startTimeSearch, endTimeSearch);
oto wynik:
10 occurences - oto Period.StartTime.Value i UTC Właściwości wystąpień
Wartość - 9/8/2015 10:30:00 - UTC 9/8/2015 17:30:00
Wartość - 9/15/2015 10:30:00 - UTC 9/15/2015 17:30:00
Wartość - 22.09.2015 10:30:00 - UTC 9/22/2015 17:30:00
Wartość - 9/29/2015 10:30:00 - UTC 9/29/2015 17:30:00
Wartość - 06.10.2015 10:30:00 - UTC 06.10.2015 17: 30:00
Wartość - 10/13/2015 10:30:00 - UTC 10/13/2015 1 7:30:00
Wartość - 20.10.2015 10:30:00 - UTC 10/20/2015 17:30:00
Wartość - 27.10.2015 10:30: 00 - UTC 27.10.2015 17:30:00
Wartość -11/3/2015 10:30:00 - UTC 03.11.2015 17:30:00 (to powinno być 18:30:00!)
Wartość - 11/10/2015 10:30:00 - UTC 10.11.2015 17:30:00 (powinno to być 18:30:00!)
Jak widać, dwa ostatnie powinny mieć czas UTC 18:30 : 00. Zastanawiam się więc, czy tak działa DDay Ical, i nie powinienem liczyć na to, że otrzymam datetime UTC, albo jeśli robię coś nie tak.
może to mieć coś wspólnego z letni? – Thorarins