Sub-day recurrences

40 views
Skip to first unread message

Mike Samuel

unread,
Apr 29, 2008, 2:39:02 PM4/29/08
to google-rfc-2445
A couple people have expressed interest in implementing sub-day
recurrences.

http://code.google.com/p/google-rfc-2445/source/browse/trunk/src/com/google/ical/iter/RecurrenceIteratorFactory.java
is the class that would have to decode the byhour rules etc., and
http://code.google.com/p/google-rfc-2445/source/browse/trunk/src/com/google/ical/iter/RRuleIteratorImpl.java
around line 253 is where the byhour/byminute/bysecond rules could be
applied.

They need to be applied before the BYSETPOS rules are evaluated in
http://code.google.com/p/google-rfc-2445/source/browse/trunk/src/com/google/ical/iter/InstanceGenerators.java

It might help to define generators (see Generators.java) for each of
Hour/Minute/Second and extend the nested loop in
InstanceGenerators.java to invoke those generators. You would
probably have to define a generator that generates given a set, a
ByHourGenerator, and a default one that generates a single time per
day from the dtstart.

Perhaps these 3 kinds of tests would be useful
(1) Testing sub-day rules
RRULE:FREQ=HOURLY
(2) Testing longer period rules with BYHOUR
RRULE:FREQ=YEARLY;BYHOUR=4,12,20
(3) Testing interaction between BYSETPOS and other rules
RRULE:FREQ=HOURLY;BYSETPOS=3.-3
RFC 2445 has a section with a bunch of testcases.
http://code.google.com/p/google-rfc-2445/source/browse/trunk/test/com/google/ical/iter/RRuleIteratorImplTest.java
contains most of those except for the sub-day ones.

jvdneste

unread,
May 5, 2008, 5:50:33 AM5/5/08
to google-rfc-2445

If anyone is already spending time on this, give a shout. I will
mostly likely have a look at it soon.

Mike: Thanks for the above pointers. Is there a high-level document
explaining how the library is implemented?

jvdneste

unread,
May 6, 2008, 9:30:49 AM5/6/08
to google-rfc-2445

> Mike: Thanks for the above pointers. Is there a high-level document
> explaining how the library is implemented?

Nevermind, I think I understand most of it.Still figuring out some
parts...

jvdneste

unread,
May 6, 2008, 12:10:19 PM5/6/08
to google-rfc-2445

I seems to me that a *lot* of places where DateValue is used now need
DateTimeValue. I implemented some generators, and started some
refactoring on an as-needed basis, but it's turning out to be more
work than I thought it would be. (keeping unittests up to date etc.)

Anyway, I'm still on it.

Denis Hennessy

unread,
May 6, 2008, 12:47:30 PM5/6/08
to google-...@googlegroups.com
The other thing to bear in mind with sub-day recurrences is that
dealing with timezones and DST effects are really important. So, for
example, with a 30 minute recurrence there will be times where it
jumps ahead by an hour and times when it goes backwards....

Of course, it actually spits out an event every 30 minutes as you'd
expect. The important thing is to make sure that the reported times
are in the requested timezone, which is specified to the createXXX()
call, even across DST changes.

/dh

Neal Gafter

unread,
May 6, 2008, 2:42:00 PM5/6/08
to google-...@googlegroups.com
I think recurrence rules are supposed to compute raw times independent
of time zone. The time zone should be applied later to the results.

Mike Samuel

unread,
May 7, 2008, 5:00:53 AM5/7/08
to google-rfc-2445
I put together http://code.google.com/p/google-rfc-2445/wiki/LifeOfARecurrence
which is a high level design. Let me know if that answers/doesn't
answer your questions.

Mike Samuel

unread,
May 7, 2008, 5:02:20 AM5/7/08
to google-rfc-2445
I'm confused. The generators all deal with a DTBuilder which should
have all the fields you need, so the InstanceGenerators should be the
only bit that needs to generate a DateValue or DateTimeValue from the
DTBuilder.

Johan Van den Neste

unread,
May 7, 2008, 6:09:49 AM5/7/08
to google-...@googlegroups.com
but the date iterators now no longer return date values, but date time values


--
Johan Van den Neste

Mike Samuel

unread,
May 7, 2008, 2:44:14 PM5/7/08
to google-...@googlegroups.com


2008/5/7 Johan Van den Neste <jvdn...@gmail.com>:


but the date iterators now no longer return date values, but date time values

date time values are date values though.

From http://code.google.com/p/google-rfc-2445/source/browse/trunk/src/com/google/ical/values/DateTimeValue.java
public interface DateTimeValue extends DateValue, TimeValue



 

Johan Van den Neste

unread,
May 8, 2008, 2:21:06 AM5/8/08
to google-...@googlegroups.com
> date time values are date values though.

true, but you actually want to receive them as date time values

Mike Samuel

unread,
May 8, 2008, 3:43:16 PM5/8/08
to google-...@googlegroups.com
2008/5/7 Johan Van den Neste <jvdn...@gmail.com>:
> date time values are date values though.

true, but you actually want to receive them as date time values

I don't want to receive a date time value when the DTSTART has no time.
If you iterate RRULE:FREQ=DAILY with DTSTART:20080508 then you get back date values, but if you iterate the same recurrence with DTSTART:20080508T120000 then you get back date time values.

 
Reply all
Reply to author
Forward
0 new messages