• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Recurring Reminders/Calendar Events?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Recurring Reminders/Calendar Events?


  • Subject: Re: Recurring Reminders/Calendar Events?
  • From: Shane Stanley <email@hidden>
  • Date: Thu, 05 Mar 2015 13:11:57 +1100

On 5 Mar 2015, at 11:17 am, Christopher Nebel <email@hidden> wrote:

I’m pretty sure -[EKEventStore eventsMatchingPredicate:] will return occurrences of recurring events in the specified date range.

I could have sworn I tried this and it didn't work, but indeed it does. It looks like the definition of start date that EKEventStore uses is different from that used by Calendar.app, and just what the OP wanted. The question then becomes what Alex wants to do with them.

This snippet requires use of a method deprecated in 10.9 because ASObjC can't yet call methods that use blocks (hint, hint), and both the editor and subsequent applets will need access to Calendars in Security & Privacy in System Preferences.

use scripting additions
use framework "Foundation"
use framework "EventKit"

-- get the event store
set theEKEventStore to current application's EKEventStore's alloc()'s initWithAccessToEntityTypes:1 -- work around enum bug
-- get calendars that can store events
set theCalendars to theEKEventStore's calendarsForEntityType:0 -- work around enum bug. Sigh
-- get the calendars whose title is "Work" or "Home" -- change to suit
set theNSPredicate to current application's NSPredicate's predicateWithFormat_("title IN %@", {"Work", "Home"})
set calsToSearch to theCalendars's filteredArrayUsingPredicate:theNSPredicate
-- create start date and end date for occurences
set startNSDate to current application's NSDate's |date|() -- now
set endNSDate to current application's NSDate's dateWithTimeIntervalSinceNow:(7 * days) -- a week away
-- find matching events
set thePred to theEKEventStore's predicateForEventsWithStartDate:startNSDate endDate:endNSDate calendars:calsToSearch
set theEvents to (theEKEventStore's eventsMatchingPredicate:thePred)
-- get titles and display them
set eventString to (theEvents's valueForKey:"title")'s componentsJoinedByString:", "
display dialog eventString as text


-- 
Shane Stanley <email@hidden>
<www.macosxautomation.com/applescript/apps/>

 _______________________________________________
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

  • Follow-Ups:
    • Re: Recurring Reminders/Calendar Events?
      • From: Alex Hall <email@hidden>
References: 
 >Re: Recurring Reminders/Calendar Events? (From: Christopher Nebel <email@hidden>)

  • Prev by Date: Re: delay doesn't work when applet is not frontmost
  • Next by Date: Re: Recurring Reminders/Calendar Events?
  • Previous by thread: Re: Recurring Reminders/Calendar Events?
  • Next by thread: Re: Recurring Reminders/Calendar Events?
  • Index(es):
    • Date
    • Thread