Welcome to MacForumz.com!
FAQFAQ      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

iCal: doesn't return all events between two dates ?

 
   Macintosh computer (Home) -> Apple Scripts RSS
Next:  ie7 crashes on exit or close  
Author Message
Mitrokhin

External


Since: Mar 07, 2007
Posts: 9



(Msg. 1) Posted: Tue Mar 20, 2007 3:37 am
Post subject: iCal: doesn't return all events between two dates ?
Imported from groups: alt>comp>lang>applescript (more info?)

Back to top
Login to vote
Patrick Stadelmann

External


Since: Nov 12, 2003
Posts: 247



(Msg. 2) Posted: Tue Mar 20, 2007 11:22 am
Post subject: Re: iCal: doesn't return all events between two dates ? [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

In article ,
Mitrokhin wrote:

> iCal doesn't return all events between two dates,
> although it should, a bug or due to faulty code ?.

I'm also running Mac OS X 10.3.9 and this script works fine :

set start_day to date "Lundi, 1 janvier 2007 0:00:00"
set end_day to date "Mercredi, 28 février 2007 0:00:00"

tell application "iCal"

set the returned_events to every event of calendar 1 ¬
whose (start date is greater than or equal to start_day) and ¬
(start date is less than or equal to the end_day)

end tell

It returns 7 events, which is correct :

{event 171 of calendar 1, event 187 of calendar 1, event 188 of
calendar 1, event 190 of calendar 1, event 191 of calendar 1, event
193 of calendar 1, event 194 of calendar 1}

iCal 1.5.5, AppleScript 1.9.3.

Patrick
--
Patrick Stadelmann

 >> Stay informed about: iCal: doesn't return all events between two dates ? 
Back to top
Login to vote
Mitrokhin

External


Since: Mar 07, 2007
Posts: 9



(Msg. 3) Posted: Tue Mar 20, 2007 11:24 am
Post subject: Re: iCal: doesn't return all events between two dates ? [Login to view extended thread Info.]
Imported from groups: per prev. post (more info?)

Back to top
Login to vote
Patrick Stadelmann

External


Since: Nov 12, 2003
Posts: 247



(Msg. 4) Posted: Tue Mar 20, 2007 3:38 pm
Post subject: Re: iCal: doesn't return all events between two dates ? [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

In article ,
Mitrokhin wrote:

> The calendar that's causing me trouble is called "DKdage" and it has
> one event on March 21 (Equinox) and one on March 25 (summer time),
> no matter what I do (cp. script below) it does not return the latter,
> which btw is a special event in that it's set to start on the last
> sunday in march of every year ... hmm i just added a "normal" event
> to March 24 and it came through fine, so I suppose the problem is
> somehow connected to the special character of the summertime event.

I just tried with a calendar that contains recurring event, and indeed
they are not returned ! If I remove the conditions, I get SOME
occurrences but not all.

For instance, I have a weekly event (on "Mercredi", i.e. "Wednesday")
set up since January 5, 2005. But I only get 19 events, for these dates:

date "Mercredi, 16 novembre 2005 10:00:00"
date "Mercredi, 26 octobre 2005 10:00:00"
date "Mercredi, 5 janvier 2005 10:00:00"
date "Mercredi, 27 avril 2005 10:00:00"
date "Mercredi, 11 janvier 2006 10:00:00"
date "Mercredi, 28 septembre 2005 10:00:00"
date "Mercredi, 21 septembre 2005 10:00:00"
date "Mercredi, 21 décembre 2005 10:00:00"
date "Mercredi, 31 août 2005 10:00:00"
date "Mercredi, 7 septembre 2005 10:00:00"
date "Mercredi, 22 mars 2006 10:00:00"
date "Mercredi, 7 décembre 2005 10:00:00"
date "Mercredi, 1 mars 2006 10:00:00"
date "Mercredi, 26 avril 2006 10:00:00"
date "Mercredi, 23 août 2006 10:00:00"
date "Mercredi, 13 septembre 2006 10:00:00"
date "Mercredi, 25 octobre 2006 10:00:00"
date "Mercredi, 27 décembre 2006 10:00:00"
date "Mercredi, 3 janvier 2007 10:00:00"

Very strange ! BTW, this is the code I used :

set the returned_events to every event of calendar 4 ¬

repeat with i in returned_events
start date of i -- display start date in log
end repeat

Patrick
--
Patrick Stadelmann
 >> Stay informed about: iCal: doesn't return all events between two dates ? 
Back to top
Login to vote
Mitrokhin

External


Since: Mar 07, 2007
Posts: 9



(Msg. 5) Posted: Tue Mar 20, 2007 5:59 pm
Post subject: Re: iCal: doesn't return all events between two dates ? [Login to view extended thread Info.]
Imported from groups: per prev. post (more info?)

Back to top
Login to vote
Patrick Stadelmann

External


Since: Nov 12, 2003
Posts: 247



(Msg. 6) Posted: Tue Mar 20, 2007 7:53 pm
Post subject: Re: iCal: doesn't return all events between two dates ? [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

In article ,
Mitrokhin wrote:

> The aforementioned event of march 25 still doesn't show and
> neither does events on april 2 and april 9: what they all have
> in common is, as we now would suspect, that they are recurring events
> - a pity really since I was planning to pull *historical* data from my
> calendars every now and then by way of applescript ...
> Anyway it would seem that we have in fact a bug on our hands, don't
> we !.

FWIW, Mac OS X 10.4.9 is a bit more consistent, it only returns the
first occurrence of a recurring event, and only it the first occurrence
is in the interval specified (if any).

Patrick
--
Patrick Stadelmann
 >> Stay informed about: iCal: doesn't return all events between two dates ? 
Back to top
Login to vote
Mitrokhin

External


Since: Mar 07, 2007
Posts: 9



(Msg. 7) Posted: Wed Mar 21, 2007 4:37 am
Post subject: Re: iCal: doesn't return all events between two dates ? [Login to view extended thread Info.]
Imported from groups: per prev. post (more info?)

Back to top
Login to vote
Adam Bell

External


Since: Feb 01, 2006
Posts: 3



(Msg. 8) Posted: Thu Mar 22, 2007 3:47 pm
Post subject: Re: iCal: doesn't return all events between two dates ? [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

On Mar 21, 5:48 am, Mitrokhin wrote:
> i: alt.comp.lang.applescript
> dato: Tue, 20 Mar 2007 23:16:55 +0100
> msgID:
> titel: Re: iCal: doesn't return all events between two dates ?
> skrev: Patrick Stadelmann
> =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
>
> : In article ,
> : Mitrokhin wrote:
> :
> : > The aforementioned event of march 25 still doesn't show and
> : > neither does events on april 2 and april 9: what they all have
> : > in common is, as we now would suspect, that they are recurring events
> : > - a pity really since I was planning to pull *historical* data from my
> : > calendars every now and then by way ofapplescript...
> : > Anyway it would seem that we have in fact a bug on our hands, don't
> : > we !.
> :
> : FWIW, Mac OS X 10.4.9 is a bit more consistent, it only returns the
> : first occurrence of a recurring event, and only it the first occurrence
> : is in the interval specified (if any).
> :
>
> I see, still not what I had hoped for ... Alas you can't have it all I
> suppose :(
>
> have a nice day
>
> --
> Regards
> Mitrokhin.

iCal does not return recurring events to AppleScripts dealing with a
span of time if the first or original event is not in the span.
Events, however, have a property called "recurrence" and your script
has to find the first event and calculate whether it has a date in
your span. Since recurrence just returns "" if it is not a repeating
event, it is easy to find them. I simply look at all events, get the
summary, date and recurrence of each like this:

set today to (current date)
set span to 90 * days

-- Build the Medical List "MAppt" {name, date, name, date, ...}
tell application "iCal"
reload calendars
close window 1
set MCals to every calendar whose title contains "Medical"
set mCal to item 1 of MCals
set toGo to {}
-- Collect the date/name list as mdCal
set mCount to count events of mCal
set mdEvent to {}
set mdDate to {}
--set all to {}
repeat with n from 1 to mCount
-- Get summary, start date, and recurrence of each
tell event n of mCal to set {anEvent, aDate, Rep} to {summary of it,
start date of it, recurrence of it}
--set end of all to result
if Rep is not "" then
if Rep contains "Yearly" then
set Rep to (word -1 of Rep) as number
set year of aDate to (year of today) + 1
else if Rep contains "Weekly" then
set Rep to (word 6 of Rep) as number
tell (Rep * weeks) to set aDate to today + (it - ((today - aDate)
mod it))
end if
end if
if ((aDate) - today) > 0 and (aDate - today) < span then
set end of mdEvent to anEvent
set end of mdDate to aDate
end if
end repeat
end tell
-- what follows sorts the two lists on date, then presents a Growl
notification.
 >> Stay informed about: iCal: doesn't return all events between two dates ? 
Back to top
Login to vote
Mitrokhin

External


Since: Mar 07, 2007
Posts: 9



(Msg. 9) Posted: Fri Mar 23, 2007 3:32 am
Post subject: Re: iCal: doesn't return all events between two dates ? [Login to view extended thread Info.]
Imported from groups: per prev. post (more info?)

Back to top
Login to vote
Display posts from previous:   
Related Topics:
Changing Events to different Calendar in iCal - All, I'm brand new to AppleScript... and struggling. Basically, in iCal, I'm trying to move events that match a certain criteria from one Calendar to another. I've got my script cycling through all the events that I want to move, but I've got no clu...

Working with recurring events in iCal - Hi all, I am looking for a way to get some sort of summary information on calendars, I am especially interested in getting the total duration of some collection of events. iCal does not seem to provide such a funcitonnality. I did hear about Apple..

Script to remove duplicate events in iCal? - As an AppleScript newbie I'm trying to remove duplicates from an iCal calendar. Does anybody know of such a thing? My efforts are disappointing... I can not even access the properties of an event. The algorithm should be easy, I could ask iCal for..

How to make AS wait for return from an application? - My subject line is probably not too clear, but what I want to do is simple. Within a main script I open an application with e.g. tell application "SimpleText" activate open file "thedocument" end tell After browsing...

Sending events to os 8.6 from X - Hello. I have an applescript residing on a machine running 8.6 with program linking turned on. Currently, from our machine running 9 I can run the remote script with an applescript using the 'tell application "finder" of machine "xyz&quot...
   Macintosh computer (Home) -> Apple Scripts All times are: Pacific Time (US & Canada)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You can edit your posts in this forum
You can delete your posts in this forum
You can vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]