2016-08-23 73 views
0

我需要測試在指定的日期是否有內置Apple日曆應用程序中的任何事件。這是我目前的想法是僞代碼:AppleScript在Apple日曆中的指定日期是事件嗎?

// 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!" 
else 
    display dialog "Free of events!" 
end if 

回答

0

嘗試:

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