EWSoftware / PDI

A Personal Data Interchange (PDI) library that implements the vCard (RFC 2426), vCalendar, and iCalendar (RFC 2445) specifications including recurrence pattern generation
Microsoft Public License
64 stars 26 forks source link

NextInstance skips dates #5

Closed aliciagontarek closed 7 years ago

aliciagontarek commented 7 years ago

If a start date is on the 29th and the NextInstance falls in Feb (based on frequency), that month will be skipped if not a Leap Year. For example, start date is 5/29/17, frequency is 9 months, the next instance displayed is 11/29/18. It also does this if the start date is 2/29 and frequency is yearly, it will only return the leap years. I was able to work around this by setting a ByMonthDay -1 for that scenario, but monthly frequency is more difficult.

EWSoftware commented 7 years ago

This is by design per the specification. If BYxxx rule parts are found that exceed the available scope (in this case Feb 29th in a non-leap year), the instances are ignored. To handle this, you can use the BYSETPOS rule to get the last occurrence that falls on either the 28th or 29th. For example:

FREQ=MONTHLY;INTERVAL=9;BYMONTHDAY=28,29;BYSETPOS=-1

Here, BYMONTHDAY=28,29 computes the 28th and 29th at the given monthly interval and BYSETPOS=-1 limits it to the last in the set. For February of non-leap years, that will be the 28th and for all other months, it will be the 29th.

aliciagontarek commented 7 years ago

Cool. I’ll give that a shot. Thanks!

Alicia Gontarek Senior Developer

From: Eric Woodruff [mailto:notifications@github.com] Sent: Tuesday, May 02, 2017 3:49 PM To: EWSoftware/PDI PDI@noreply.github.com Cc: Alicia Gontarek agontarek@membersolutions.com; Author author@noreply.github.com Subject: Re: [EWSoftware/PDI] NextInstance skips dates (#5)

This is by design per the specification. If BYxxx rule parts are found that exceed the available scope (in this case Feb 29th in a non-leap year), the instances are ignored. To handle this, you can use the BYSETPOS rule to get the last occurrence that falls on either the 28th or 29th. For example:

FREQ=MONTHLY;INTERVAL=9;BYMONTHDAY=28,29;BYSETPOS=-1

Here, BYMONTHDAY=28,29 computes the 28th and 29th at the given monthly interval and BYSETPOS=-1 limits it to the last in the set. For February of non-leap years, that will be the 28th and for all other months, it will be the 29th.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/EWSoftware/PDI/issues/5#issuecomment-298741487, or mute the threadhttps://github.com/notifications/unsubscribe-auth/Aa_4INpjuVy9Vn2bD0smFVVbioFfsIgtks5r14jBgaJpZM4NOdK1.