Michael Tesař Michael Tesař - 11 months ago 85
AppleScript Question

Is event in specified date in Apple calendar by AppleScript?

I need to test if in specified day is or is not an event in Apple calendar. In pseudocode I need followings:

// input variables
day_to_test = 23
month_to_test = 8
year_to_test = 2016
testing_date = day_to_test + month_to_test + year_to_test as date

// actual "code"
if testing_date has any event in Apple calendar Then
display dialog "There is any event on that day!"
display dialog "Free of events!"
end if



tell application "Calendar"
    tell calendar "Main" -- national holiday calendar in my iCloud 
        set today to current date
        set today's year to 2013
        set today's month to 3
        set today's day to 5
        set today's time to 0
        copy (today + days) to tomorrow
        set currentEvents to events whose start date ≥ today and end date ≤ tomorrow
    end tell
end tell