ICAL.NET 周期性元素:从开始日期到结束日期的每个星期二(每周)、每 2 个、最后一个星期一(每月)
ICAL.NET Recurring Elements: every Tuesday(weekly), Every 2nd, last Monday(monthly) from a start date to end date
ical 附件 (.ics) 适用于所有案例,但每周和每月一次的案例除外。我正在尝试为其中一个工作日创建每周重复,并为每个月的最后一个 Tuesday/2nd 星期二创建每月重复。当我打开 .ics 文件时,它显示 "The operation failed".
每周:
evnt.Start = new CalDateTime(start);
evnt.End = new CalDateTime(new DateTime(evnt.Start.Year, evnt.Start.Month, evnt.Start.Day, end.Hour, end.Minute, end.Second));
rrule = new RecurrencePattern(FrequencyType.Weekly, 1);
rrule.ByDay.Add(new WeekDay(DayOfWeek.Monday));
rrule.Until = end;
evnt.RecurrenceRules = new List<RecurrencePattern> { rrule };
每月:
evnt.Start = new CalDateTime(start);
evnt.End = new CalDateTime(new DateTime(evnt.Start.Year, evnt.Start.Month, evnt.Start.Day, end.Hour, end.Minute, end.Second));
rrule = new RecurrencePattern(FrequencyType.Monthly,1);
rrule.Until = end;
rrule.ByDay.Add(new WeekDay(DayOfWeek.Sunday,FrequencyOccurrence.FifthToLast));
evnt.RecurrenceRules = new List<RecurrencePattern> { rrule };
请让我知道我做错了什么。
能否提供您的代码将输出的 iCalendar 数据?并可能向我们展示 start
和 end
是什么。
I'm trying to create a weekly recurrence for one of the weekday
为此,iCalendar 数据应如下所示:
FREQ=WEEKLY;BYDAY=MO;INTERVAL=1;UNTIL=20200515T220000Z
我选择了星期一作为这一天,并提前一个月定下了结束日期,你也一样,提供了一些结束。
I'm trying to create a monthly recurrence for last Tuesday/2nd Tuesday of every month.
正如 @anmari 指出的那样,您的代码中有一个星期日,但您想要一个重复出现的星期二。
为此,iCalendar 应如下所示:
FREQ=MONTHLY;BYDAY=2TU,-1TU;INTERVAL=1;UNTIL=20200515T220000Z
甚至像这样(BYSETPOS
):
FREQ=MONTHLY;BYSETPOS=2,-1;BYDAY=TU;INTERVAL=1;UNTIL=20200515T220000Z
根据我从@matis 和@anmari 那里得到的线索,我找到了根本原因。
当您创建具有特定工作日的定期约会时,开始日期和结束日期都应与同一工作日匹配。这是在每个月的第二个星期三发生的工作示例。
BEGIN:VCALENDAR
METHOD:PUBLISH
PRODID:-//github.com/rianjs/ical.net//NONSGML ical.net 4.0//EN
VERSION:2.0
BEGIN:VEVENT
ATTENDEE;CN="Last, First":mailto:first.last@email.com
CREATED:20200415T164742
DESCRIPTION: Cal Description
DTEND;TZID=Eastern Standard Time:20200513T110000
DTSTAMP:20200415T204742Z
DTSTART;TZID=Eastern Standard Time:20200513T103000
LOCATION:Meeting location
ORGANIZER;CN="user, Admin";SENT-BY="mailto:admin.user@email.com":
RRULE:FREQ=MONTHLY;COUNT=13;BYDAY=2WE
SEQUENCE:0
SUMMARY:Title
UID:1913d514-696e-4237-bc3c-c1d073eacced
BEGIN:VALARM
ACTION:DISPLAY
DESCRIPTION:Reminder
TRIGGER:-PT15M
END:VALARM
END:VEVENT
END:VCALENDAR
ical 附件 (.ics) 适用于所有案例,但每周和每月一次的案例除外。我正在尝试为其中一个工作日创建每周重复,并为每个月的最后一个 Tuesday/2nd 星期二创建每月重复。当我打开 .ics 文件时,它显示 "The operation failed".
每周:
evnt.Start = new CalDateTime(start);
evnt.End = new CalDateTime(new DateTime(evnt.Start.Year, evnt.Start.Month, evnt.Start.Day, end.Hour, end.Minute, end.Second));
rrule = new RecurrencePattern(FrequencyType.Weekly, 1);
rrule.ByDay.Add(new WeekDay(DayOfWeek.Monday));
rrule.Until = end;
evnt.RecurrenceRules = new List<RecurrencePattern> { rrule };
每月:
evnt.Start = new CalDateTime(start);
evnt.End = new CalDateTime(new DateTime(evnt.Start.Year, evnt.Start.Month, evnt.Start.Day, end.Hour, end.Minute, end.Second));
rrule = new RecurrencePattern(FrequencyType.Monthly,1);
rrule.Until = end;
rrule.ByDay.Add(new WeekDay(DayOfWeek.Sunday,FrequencyOccurrence.FifthToLast));
evnt.RecurrenceRules = new List<RecurrencePattern> { rrule };
请让我知道我做错了什么。
能否提供您的代码将输出的 iCalendar 数据?并可能向我们展示 start
和 end
是什么。
I'm trying to create a weekly recurrence for one of the weekday
为此,iCalendar 数据应如下所示:
FREQ=WEEKLY;BYDAY=MO;INTERVAL=1;UNTIL=20200515T220000Z
我选择了星期一作为这一天,并提前一个月定下了结束日期,你也一样,提供了一些结束。
I'm trying to create a monthly recurrence for last Tuesday/2nd Tuesday of every month.
正如 @anmari 指出的那样,您的代码中有一个星期日,但您想要一个重复出现的星期二。
为此,iCalendar 应如下所示:
FREQ=MONTHLY;BYDAY=2TU,-1TU;INTERVAL=1;UNTIL=20200515T220000Z
甚至像这样(BYSETPOS
):
FREQ=MONTHLY;BYSETPOS=2,-1;BYDAY=TU;INTERVAL=1;UNTIL=20200515T220000Z
根据我从@matis 和@anmari 那里得到的线索,我找到了根本原因。
当您创建具有特定工作日的定期约会时,开始日期和结束日期都应与同一工作日匹配。这是在每个月的第二个星期三发生的工作示例。
BEGIN:VCALENDAR
METHOD:PUBLISH
PRODID:-//github.com/rianjs/ical.net//NONSGML ical.net 4.0//EN
VERSION:2.0
BEGIN:VEVENT
ATTENDEE;CN="Last, First":mailto:first.last@email.com
CREATED:20200415T164742
DESCRIPTION: Cal Description
DTEND;TZID=Eastern Standard Time:20200513T110000
DTSTAMP:20200415T204742Z
DTSTART;TZID=Eastern Standard Time:20200513T103000
LOCATION:Meeting location
ORGANIZER;CN="user, Admin";SENT-BY="mailto:admin.user@email.com":
RRULE:FREQ=MONTHLY;COUNT=13;BYDAY=2WE
SEQUENCE:0
SUMMARY:Title
UID:1913d514-696e-4237-bc3c-c1d073eacced
BEGIN:VALARM
ACTION:DISPLAY
DESCRIPTION:Reminder
TRIGGER:-PT15M
END:VALARM
END:VEVENT
END:VCALENDAR