使用 Applescript 从 iCal 获取今天的活动

发布于 2024-11-05 09:37:12 字数 667 浏览 1 评论 0原文

我迭代 iCal 中的所有事件以仅获取今天的事件,但我认为这效率不高。有没有一个函数/方法可以只获取今天的事件?

tell application "iCal"
    tell calendar "Lotus Notes"
        set today to (current date)
        set this_year to year of today
        set this_month to month of today
        set this_day to day of today

        repeat with c in every event
            set d to start date of c
            set the_year to year of d
            set the_month to month of d
            set the_day to day of d
            if (the_year = this_year) and (the_month = this_month) and (the_day = this_day) then
                show c
            end if
        end repeat
    end tell
end tell

I iterate over all the events in iCal to get only today's events, but I don't think this is efficient. Is there a function/method to get only today's events?

tell application "iCal"
    tell calendar "Lotus Notes"
        set today to (current date)
        set this_year to year of today
        set this_month to month of today
        set this_day to day of today

        repeat with c in every event
            set d to start date of c
            set the_year to year of d
            set the_month to month of d
            set the_day to day of d
            if (the_year = this_year) and (the_month = this_month) and (the_day = this_day) then
                show c
            end if
        end repeat
    end tell
end tell

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

绝影如岚 2024-11-12 09:37:12

试试这个:

set {year:y, month:m, day:d} to current date
set str to (m as string) & " " & (d as string) & " " & (y as string)
set today to date str
set tomorrow to today + 60 * 60 * 24

tell application "iCal"
    tell calendar "Lotus Notes"
        set curr to every event whose start date is greater than or equal to today ¬
            and start date is less than or equal to tomorrow
    end tell
end tell

Try this:

set {year:y, month:m, day:d} to current date
set str to (m as string) & " " & (d as string) & " " & (y as string)
set today to date str
set tomorrow to today + 60 * 60 * 24

tell application "iCal"
    tell calendar "Lotus Notes"
        set curr to every event whose start date is greater than or equal to today ¬
            and start date is less than or equal to tomorrow
    end tell
end tell
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文