Hi again, I encountered another problem now. here is a testcase to reproduce it: $ ruby -rvpim/icalendar -ropen-uri -e ''a = Vpim::Icalendar.decode(open("http://ical.mac.com/ical/Japanese32Holidays.ics").read); a[0].events.each {|e| begin r = e.occurences; r.each(Time.local(2007)) {|f| }; rescue ArgumentError; p r; raise; end;}'' It includes some yearly events and it''s endless. so I did with dountil parameter. however the result of this testcase was: #<Vpim::Rrule:0xb7d44d1c @dtstart=Mon Jul 21 00:00:00 UTC 2003, @by={"BYMONTH"=>"7", "BYDAY"=>"3MO"}, @until=nil, @wkst="MO", @freq="YEARLY", @interval=1, @rrule="FREQ=YEARLY;INTERVAL=1;BYMONTH=7;BYDAY=3MO", @count=nil> /usr/lib/ruby/1.8/vpim/time.rb:21:in `local'': time out of range (ArgumentError) from /usr/lib/ruby/1.8/vpim/time.rb:21:in `plus_year'' from /usr/lib/ruby/1.8/vpim/rrule.rb:288:in `each'' from /usr/lib/ruby/1.8/vpim/rrule.rb:151:in `loop'' from /usr/lib/ruby/1.8/vpim/rrule.rb:151:in `each'' from -e:1 from -e:1:in `each'' from -e:1 It seems because there was no yield from days in rrule.rb:252. so dountil was never checked in this case. though I''m not sure if DaySet should yields anyway, attached patch to be safe solved this problem for me. Any comments? Regards, -- Akira TAGOH : tagoh@gnome.gr.jp / Japan GNOME Users Group at@gclab.org : tagoh@gnome-db.org / GNOME-DB Project : tagoh@redhat.com / Red Hat, Inc. : tagoh@debian.org / Debian Project -------------- next part -------------- --- rrule.rb.orig 2005-01-23 21:45:13.000000000 +0900 +++ rrule.rb 2005-01-23 21:46:13.000000000 +0900 @@ -308,6 +308,7 @@ when nil return self end + return self if dountil && (t > dountil) end end
Sam Roberts
2005-Jan-23 17:14 UTC
[Vpim-talk] problems with Apple calendars (was time out of range occurs)
Thanks for this. I had seen this, too, but hadn''t got around to fixing it. There are a few things happening here. - 1 bug Yes, you have have correctly identified it. What is happening, is that if a RRULE never results in any events, it never reaches the place where the dountil is checked. Your patch correctly fixes this, thank you. - 2 useability Why not just end the iteration with no error when the boundary of representable time is reached, rather than forcing people to provide a dountil? dountil is still useful as an optimization (if you are only interested in recurrences before the end of the year, might as well say so). Any opinions on this? I''ve added it and I think I like it. - 3 interop I believe Apple has a bug in their calendar files, and not just in the Japanese one. This bug may be related to a bug I observe in their iCal.app, too. Because of the bug, the recurrence rule for what they want to be the third Monday in July never actually occurs! RRULE:FREQ=yearly;INTERVAL=1;BYMONTH=n;BYDAY=2MO They think this means the 2nd monday in month n, but it doesn''t. It means the 2nd monday in the YEAR, if it occurs in month n. I don''t know what to do about this. You can see a related bug if you code the following example from the RFC into an ics file (attached): Every 20th Monday of the year, forever: DTSTART;TZID=US-Eastern:19970519T090000 RRULE:FREQ=YEARLY;BYDAY=20MO ==> (1997 9:00 AM EDT)May 19 (1998 9:00 AM EDT)May 18 (1999 9:00 AM EDT)May 17 ... Adding a BYMONTH to this wouldn''t mean the BYDAY=20MO suddenly means the 20th monday in the month, when it used to mean the 20th monday of the year. The above ics file is mangled by iCal.app. What Apple should say for "3 MO of July" is not: FREQ=YEARLY;INTERVAL=1;BYMONTH=7;BYDAY=3MO but ./rrule.rb --start "Mon Jul 18 16:32:33 EST 2005" ''FREQ=MONTHLY;INTERVAL=12;BYDAY=3MO'' or (less efficient): ./rrule.rb --start "Mon Jul 18 16:32:33 EST 2005" ''FREQ=MONTHLY;INTERVAL=1;BYMONTH=7;BYDAY=3MO'' I don''t have a clue what to do about this. I think the "right" thing to do is to allow the processing rules to be changed, so that if the user chooses "apple rules" or if we notice the PRODID is Apple we interpret the rules their way, otherwise we do it the right way. I don''t have the time to code this up right now but I will have to do it eventually, because I use Candian32Holidays.ics from Apple, and it has similar errors to the Japanese calendar you are using. If anybody on this list has the time or ability to test either http://ical.mac.com/ical/Japanese32Holidays.ics http://ical.mac.com/ical/Canadian32Holidays.ics to see if the 3MO in July is a japanese holiday, or the first MO in August is a Canadian holiday, that would be great. I would like to know how widespread this is. Also, I''m curious about the attached bug.ics, is it correctly showing up as the 20th monday of the year in other calendar programs? Cheers, Sam Quoteing at@gclab.org, on Sun, Jan 23, 2005 at 09:50:47PM +0900:> Hi again, > > I encountered another problem now. here is a testcase to > reproduce it: > > $ ruby -rvpim/icalendar -ropen-uri -e ''a = Vpim::Icalendar.decode(open("http://ical.mac.com/ical/Japanese32Holidays.ics").read); a[0].events.each {|e| begin r = e.occurences; r.each(Time.local(2007)) {|f| }; rescue ArgumentError; p r; raise; end;}'' > > It includes some yearly events and it''s endless. so I did > with dountil parameter. however the result of this testcase > was: > #<Vpim::Rrule:0xb7d44d1c @dtstart=Mon Jul 21 00:00:00 UTC 2003, @by={"BYMONTH"=>"7", "BYDAY"=>"3MO"}, @until=nil, @wkst="MO", @freq="YEARLY", @interval=1, @rrule="FREQ=YEARLY;INTERVAL=1;BYMONTH=7;BYDAY=3MO", @count=nil> > /usr/lib/ruby/1.8/vpim/time.rb:21:in `local'': time out of range (ArgumentError) > from /usr/lib/ruby/1.8/vpim/time.rb:21:in `plus_year'' > from /usr/lib/ruby/1.8/vpim/rrule.rb:288:in `each'' > from /usr/lib/ruby/1.8/vpim/rrule.rb:151:in `loop'' > from /usr/lib/ruby/1.8/vpim/rrule.rb:151:in `each'' > from -e:1 > from -e:1:in `each'' > from -e:1 > > It seems because there was no yield from days in > rrule.rb:252. so dountil was never checked in this > case. though I''m not sure if DaySet should yields anyway, > attached patch to be safe solved this problem for me. > > Any comments? > > Regards, > -- > Akira TAGOH : tagoh@gnome.gr.jp / Japan GNOME Users Group > at@gclab.org : tagoh@gnome-db.org / GNOME-DB Project > : tagoh@redhat.com / Red Hat, Inc. > : tagoh@debian.org / Debian Project> --- rrule.rb.orig 2005-01-23 21:45:13.000000000 +0900 > +++ rrule.rb 2005-01-23 21:46:13.000000000 +0900 > @@ -308,6 +308,7 @@ > when nil > return self > end > + return self if dountil && (t > dountil) > end > end >> _______________________________________________ > Vpim-talk mailing list > Vpim-talk@rubyforge.org > http://rubyforge.org/mailman/listinfo/vpim-talk-------------- next part -------------- A non-text attachment was scrubbed... Name: bug.ics Type: text/calendar Size: 248 bytes Desc: not available Url : http://rubyforge.org/pipermail/vpim-talk/attachments/20050123/b2cfd433/bug.bin