[Pythonmac-SIG] Scripting iCal :: getting the events of the day?

Paul Berkowitz berkowit at silcom.com
Wed Jul 7 05:13:00 CEST 2004


On 7/6/04 7:56 PM, "Paul Berkowitz" <berkowit at silcom.com> wrote:

> It's not so ornate as all that. iCal stores its events in separate calendars,
> so you have to search per calendar. It implements 'whose clauses' for quick
> searching. Here's how to do it in pure AppleScript, which doesn't really
> belong on this list. You should join the AppleScript-Users mailing list, on
> Apple's website.
> 
> set today to (current date) --or date "8/1/2004"
> set time of today to 0 -- midnight, if not
> set tomorrow to today + (1 * days)
> tell application "iCal"
>     set dayEvents to {}
>     repeat with c in (every calendar)
>         set end of dayEvents to (every event of c whose start date „ today and
> start date < tomorrow)
>     end repeat
> end tell
> return dayEvents

Sorry, that will give you a list of lists rather than a simple list (array).
This is better:

set today to (current date) --or date "8/1/2004"
set time of today to 0 -- midnight, if not
set tomorrow to today + (1 * days)
tell application "iCal"
    set dayEvents to {}
    repeat with c in (every calendar)
        set dayEvents to dayEvents & (every event of c whose start date „
today and start date < tomorrow)
    end repeat
end tell
return dayEvents


However, due to a really stupid bug in iCal, that will not give you all-day
events for today unless you know how to do it. (iCal thinks the start time
is your local equivalent of what it would be if it were midnight GMT.) Write
me privately and I'll send you a script that deals with those and excludes
tomorrow's (or yesterday's) all-day events.
-- 
Paul Berkowitz

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/pythonmac-sig/attachments/20040706/139561b4/attachment-0001.htm


More information about the Pythonmac-SIG mailing list