在 AppleScript 的指定日历中查找事件

Find event in specified calendar in AppleScript

你好,我是 AppleScript 的新手。我尝试通过纯 AppleScript 创建出勤生成器(我知道我会使用 Microsoft Excel VBA 为此我只想使用 AppleScript。)。

我有这样的问题。我想检查当月是否有一些国定假日(称为 "Státní svátky" 的日历)。我 运行 我的代码并变成空的,例如 {} 变量。不知道我的代码有什么问题。

-- My isholiday function; i parameter is pointer to day of month i want to test if it is or it is not a holiday
on isholiday(i)

    -- Function global variables
    set today to current date
    set tomorrow to today + 60 * 60 * 24

    -- work with calendar app
    tell application "Calendar"
        tell calendar "Státní svátky" -- national holiday calendar in my iCloud 
            set currentEvent to every event whose start date is greater than or equal to today and start date is less than or equal to tomorrow
            return currentEvent

            -- when an event occurs it should tells me right
            if currentEvent is not {} then
                display dialog "It is not empty!"
            end if
        end tell
    end tell
end isholiday

-- 调用函数 - 我特意选择了 23 - 我那天做了测试事件,例如,我知道它不是 100% 空的 假期(23)

请帮帮我。谢谢!

-- 迈克尔

具有重复事件的日历通常不使用当年的开始日期。我会用这个检查开始和结束日期...

tell application "Calendar"
    tell calendar "Státní svátky" -- national holiday calendar in my iCloud 
        return start date of events whose summary = "a holiday name"
    end tell
end tell

编辑
确认开始日期正确后,您可以按照以下方式使用某些内容...

tell application "Calendar"
    tell calendar "Státní svátky" -- national holiday calendar in my iCloud 
        set today to current date
        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