Sander Koning | 10 Apr 2007 11:36
Favicon

Quarterly appointments


Hello,

I'm working on iCalendar import/export for the reservations module in 
our product. So far, everything works quite fine, apart from the fact 
that we support quarterly reservations. For example, "every second 
Tuesday of each quarter" or "every 70th day of each odd quarter".

As iCalendar does not support FREQ=QUARTERLY, I will have to rewrite 
these recurrence rules. Of course I can go and calculate everything 
manually in my code, but that is bound to contain errors. So, if anybody 
has got suggestions about how to tackle this, they would be most welcome.

If this is the wrong list to ask, then a pointer to the right place is 
fine as well, of course.

Thanks in advance,

Cheers,

--

-- 
Sander Koning
TOPdesk Ontwikkeling

TOPdesk
Martinus Nijhofflaan 2, 2624 ES Delft
Postbus 559, 2600 AN Delft

T  (015) 270 09 00
F  (015) 257 52 56
(Continue reading)

Mike Samuel | 10 Apr 2007 22:43
Picon
Gravatar

Re: Quarterly appointments


Since the quarters have length (90 || 91), (91), (92), (92), the n-th
day of each quarter is
    BYYEARDAY=$(n),$(-(92+92+91+1-n)),$(-(92+92+1-n)),$(-(92+1-n)),
for n in [1, 90]

You can't do
  FREQ=QUARTERLY;BYDAY=2TU
in a single rule with freq=monthly and interval unless you're sure
that the n-th week falls in the first or last month of the quarter.

You can do it with multiple rrules though
  FREQ=YEARLY;BYMONTH=1,2,3;BYDAY=2TU;BYSETPOS=1
  FREQ=YEARLY;BYMONTH=4,5,6;BYDAY=2TU;BYSETPOS=1
  FREQ=YEARLY;BYMONTH=7,8,9;BYDAY=2TU;BYSETPOS=1
  FREQ=YEARLY;BYMONTH=10,11,12;BYDAY=2TU;BYSETPOS=1

The BYSETPOS should always have magnitude 1 but should have the same
sign as the BYDAY clause.

You can do intervals on quarters by filtering out some of the rules
and/or multiplying the set of rules and applying yearly intervals.

Handling multiple BYDAY clauses is going to require a set of RRULEs
per clause though.

On 10/04/07, Sander Koning <s.koning <at> topdesk.com> wrote:
>
> Hello,
>
(Continue reading)

Preston Stephenson | 10 Apr 2007 19:17
Picon

Re: Quarterly appointments


Sorry, its been a while since I've done ICal.
Here is what I did.
RRULE:FREQ=MONTHLY;UNTIL=20080410;INTERVAL=4;BYDAY=2TU

That should work.
Preston

>>> On Tuesday, April 10, 2007 at 3:36 AM, Sander Koning <s.koning <at> topdesk.com>
wrote:

> Hello,
> 
> I'm working on iCalendar import/export for the reservations module in 
> our product. So far, everything works quite fine, apart from the fact 
> that we support quarterly reservations. For example, "every second 
> Tuesday of each quarter" or "every 70th day of each odd quarter".
> 
> As iCalendar does not support FREQ=QUARTERLY, I will have to rewrite 
> these recurrence rules. Of course I can go and calculate everything 
> manually in my code, but that is bound to contain errors. So, if anybody 
> has got suggestions about how to tackle this, they would be most welcome.
> 
> If this is the wrong list to ask, then a pointer to the right place is 
> fine as well, of course.
> 
> Thanks in advance,
> 
> Cheers,

(Continue reading)

Preston Stephenson | 10 Apr 2007 19:41
Picon

Re: Quarterly appointments


Sorry, I was looking a at a different calendar that was four months wide.
You would do INTERVAL=3 for every 3 months.

Preston

>>> On Tuesday, April 10, 2007 at 11:17 AM, "Preston Stephenson"
<PStephenson <at> gw.novell.com> wrote:

> Sorry, its been a while since I've done ICal.
> Here is what I did.
> RRULE:FREQ=MONTHLY;UNTIL=20080410;INTERVAL=4;BYDAY=2TU
> 
> That should work.
> Preston
> 
>>>> On Tuesday, April 10, 2007 at 3:36 AM, Sander Koning <s.koning <at> topdesk.com>
> wrote:
> 
>> Hello,
>> 
>> I'm working on iCalendar import/export for the reservations module in 
>> our product. So far, everything works quite fine, apart from the fact 
>> that we support quarterly reservations. For example, "every second 
>> Tuesday of each quarter" or "every 70th day of each odd quarter".
>> 
>> As iCalendar does not support FREQ=QUARTERLY, I will have to rewrite 
>> these recurrence rules. Of course I can go and calculate everything 
>> manually in my code, but that is bound to contain errors. So, if anybody 
>> has got suggestions about how to tackle this, they would be most welcome.
(Continue reading)


Gmane