AppleScript的Apple日历中指定日期的事件是?

时间:2016-08-23 11:21:32

标签: events applescript

我需要测试在指定日期内置Apple Calendar应用程序中是否有任何事件。这是我目前的想法,即伪代码:

// 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

1 个答案:

答案 0 :(得分: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