嗨,我有这个ical(1.0 beta)
我有这个代码
IICalendarCollection iCal = iCalendar.LoadFromStream(fileStream);
foreach (var ic in iCal)
{
foreach (var evt in ic.Events)
{
DateTime now = DateTime.UtcNow.Date;
if (evt.Start.UTC.Date.CompareTo(now) >= 0 && evt.End.UTC.Date.CompareTo(now) >= 0)
{
foreach (var rule in evt.RecurrenceRules)
{
if (rule.Frequency == FrequencyType.Daily)
{
// always false until is never set.
bool doesRepeatingEnd = DoesRepeatingEnd(rule);
if (doesRepeatingEnd)
{
TimeSpan until = now.Subtract(rule.Until);
int days = until.Days;
}
else { }
} else if (rule.Frequency == FrequencyType.Weekly)
{
}
else if (rule.Frequency == FrequencyType.Monthly)
{
}
else if (rule.Frequency == FrequencyType.Yearly)
{
}
}
} }
}
private static bool DoesRepeatingEnd(IRecurrencePattern rule)
{
DateTime until = rule.Until;
return until != DateTime.MinValue;
}
我以(ical 格式)导入谷歌日历
BEGIN:VCALENDAR
PRODID:-//Google Inc//Google Calendar 70.9054//EN
VERSION:2.0
CALSCALE:GREGORIAN
METHOD:PUBLISH
X-WR-CALNAME:
Name X-WR-TIMEZONE:America/Washington
BEGIN:VTIMEZONE
TZID:America/Washington
X-LIC-LOCATION:America/Washington
BEGIN:DAYLIGHT
TZOFFSETFROM:-0800
TZOFFSETTO:-0700
TZNAME:PDT
DTSTART:19700308T020000
RRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=2SU
END:DAYLIGHT
BEGIN:STANDARD
TZOFFSETFROM:-0700
TZOFFSETTO:-0800
TZNAME:PST
DTSTART:19701101T020000
RRULE:FREQ=YEARLY;BYMONTH=11;BYDAY=1SU
END:STANDARD
END:VTIMEZONE
BEGIN:VEVENT
DTSTART;VALUE=DATE:20110530
DTEND;VALUE=DATE:20110531
RRULE:FREQ=DAILY;UNTIL=20110604
DTSTAMP:20110424T202756Z
UID:fl16scis3l3qmhrrbb6uhkmo98@google.com
CREATED:20110424T202406Z
DESCRIPTION:
LAST-MODIFIED:20110424T202406Z
LOCATION:
SEQUENCE:0
STATUS:CONFIRMED
SUMMARY:dd
TRANSP:TRANSPARENT
END:VEVENT
END:VCALENDAR
如您所见,我有 RRULE:FREQ=DAILY;UNTIL=20110604
,但我的代码永远不会选择它。直到总是像默认日期时间一样。
有人有想法么?
谢谢