libical / XbICalendar

Objective-C Wrapper for the libical library
Other
17 stars 19 forks source link

about the icalcomponent_foreach_recurrence #32

Closed nyz110 closed 9 years ago

nyz110 commented 9 years ago

BEGIN:VCALENDAR PRODID:-//ACME/DesktopCalendar//EN METHOD:REQUEST VERSION:2.0 BEGIN:VEVENT DTSTART:19700308T020000 DTEND:19970701T190000Z ORGANIZER:Mailto:A@example.com ATTENDEE;ROLE=CHAIR;PARTSTAT=ACCEPTED;CUTYPE=INDIVIDUAL:A@example.COM ATTENDEE;RSVP=TRUE;CUTYPE=INDIVIDUAL:B@example.fr ATTENDEE;RSVP=TRUE;CUTYPE=INDIVIDUAL:c@example.jp DTSTAMP:19970613T190030Z DTSTART;TZID=America-SanJose:19970701T140000 DTEND;TZID=America-SanJose:19970701T150000 RRULE:FREQ=DAILY;INTERVAL=2;WKST=SU SUMMARY:Dayly Phone Conference UID:calsrv.example.com-873970198738780@example.com SEQUENCE:0 STATUS:CONFIRMED END:VEVENT END:VCALENDAR

above is my ics file content,when I call icalcomponent_foreach_recurrence to calculate recurrences between 2015/8/1 and 2015/8/31 .but callback method be called 5000 times. I am suspicious of libical.a has bug about this? is libical.a compiled on the latest ical source code

https://github.com/libical/libical/issues/66 this is fixed issues

ahalls commented 9 years ago

The current build of the libical archive here is from the last release tag v1.0.1 not the bleeding edge.

nyz110 commented 9 years ago

thanks ahalls,i find why,the method icalcomponent_foreach_recurrence is right,the event lasts for 27 years, so a lot of occurrences callback whose occur timespan(start,end) contain the range i have passed(starttime,endtime). but i want ignore the event's end date when calculate recurrences,like iCal4j framework calculate without dtend .now i solve it ,just before calling the method icalcomponent_foreach_recurrence,set the event component dtend equal to dtstart : struct icaltimetype dtstart = icalcomponent_get_dtstart(eventComp); icalcomponent_set_dtend(eventComp, dtstart); if others have the same demand ,you can do as me.

ahalls commented 9 years ago

Looks like we can add a check to the code to prevent crashing on bad data files.

"If you check the parsed data with icalrestriction_check() before trying to use it, the multiple DTSTART/DTEND should get caught."

I will add this the next time I work with the code.

I'm thinking of having the thec check as default behavior with the ability to turn it off with a internal setting.

nyz110 commented 9 years ago

Yes,we avoid some bad datas by calling icalcomponent_strip_errors() after parsing ics content