Re: Getting recurring event instance for specific day in iCal
Re: Getting recurring event instance for specific day in iCal
- Subject: Re: Getting recurring event instance for specific day in iCal
- From: "Nigel Garvey" <email@hidden>
- Date: Sun, 8 Jun 2008 23:06:07 +0100
Loren Ryter wrote on Sun, 08 Jun 2008 07:43:35 -0400:
>I would add that:
>
>1. people have written subroutines for parsing the recurrence property but
>that it's complicated and you may want to avoid it. Scott Tooker wrote a
>decent one in 2003 for Today's Schedule widget. I believe I saw another
>more recent variant on Script Builders at macscripter.
Code Exchange, actually.
<http://bbs.macscripter.net/viewtopic.php?id=23877>
You supply the main handler with an event's 'recurrence' text, its 'start
date', and the date on or after which you want to know the next
recurrence, and it uses vanilla AppleScript to work out the recurrence
date. If the start date comes after the reference date, the start date
itself is returned as the next recurrence, even if the event doesn't
actually repeat. If there's no next recurrence, the script returns
'missing value'.
The script's limited in that it's only geared to second-guess recurrences
that can been set up in iCal's Info drawer and which haven't been
modified by the dragging around of individual recurrences in the calendar
display. I've been meaning to enhance it so that it'll also work with
recurrence rules that iCal obeys but doesn't implement through its GUI,
but a complete rewrite's probably needed for that. Maybe one day. The
main handler is getNextRecurrence():
tell application "iCal"
activate
set theEvent to first event of calendar "Personal" whose summary =
"Gym" and start date = "Saturday, June 7, 2008 9:45AM"
-- The start date's just been used to get the event, but what the hell.
set {start date:startDate, recurrence:recurrenceRule} to theEvent
end tell
set today to (current date)
-- Get the date of the next recurrence after today,
-- or today's recurrence if there is one.
set nextRecurrence to getNextRecurrence(recurrenceRule, startDate, today)
There doesn't appear to be any way to select any instance of a recurring
event except for the original on the start date. An unsatisfactory
alternative might be to select the original, so that its summary appears
in the info drawer, and then switch the view to the recurrence date. :
tell application "iCal"
show theEvent
view calendar at nextRecurrence
end tell
NG
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden