Skip to content

Instantly share code, notes, and snippets.

@vtim
Created January 21, 2013 14:37
Show Gist options
  • Save vtim/4586508 to your computer and use it in GitHub Desktop.
Save vtim/4586508 to your computer and use it in GitHub Desktop.
Query iCal events from MacRuby
#!/usr/local/bin/macruby
framework 'calendarstore'
thirty_days_ago = NSDate.dateWithString((Time.now - (30 * 3600 * 24)).to_s)
today = NSDate.date
store = CalCalendarStore.defaultCalendarStore
predicate = CalCalendarStore.eventPredicateWithStartDate(thirty_days_ago, endDate:today, calendars:CalCalendarStore.defaultCalendarStore.calendars)
store.eventsWithPredicate(predicate).each do |event|
if event.title.downcase.include? "test"
puts "#{event.startDate.strftime('%d-%m-%y')}\t#{event.title}"
end
end
08-01-13 New Test
15-01-13 iOS test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment