简体   繁体   English

无法在 AppleScript 日历中获取重复事件的实例

[英]Cannot get instance of recurring event in AppleScript Calendar

I have a script that performs actions on events in the next 30 days.我有一个脚本可以在接下来的 30 天内对事件执行操作。 I use the following command to get stamp dates for all events between eventStart (today) and eventEnd (today + 30).我使用以下命令获取 eventStart(今天)和 eventEnd(今天 + 30)之间所有事件的时间戳日期。

set newStamps to get stamp date of (every event of calendar myCal whose start date is greater than eventStart and start date is less than eventEnd and allday event is false)

This returns stamps of events which are not repeated, and it misses stamps from repeated events (from an event with stamp before eventStart but has repeating instances within eventStart and eventEnd)这将返回不重复的事件戳记,并且它会错过重复事件的戳记(来自事件开始之前带有戳记但在 eventStart 和 eventEnd 中具有重复实例的事件)

How can I return all events regardless of whether they are repeated or not?我怎样才能返回所有事件,无论它们是否重复?

A repeated event has only one real instance - the very first one.一个重复的事件只有一个真实的例子——第一个。 The rest of the events corresponding to this instance are calculated on the fly by the Calendar.app itself, this is a virtual approximation that the script cannot get by requesting the Calendar.app.此实例对应的事件的 rest 是由 Calendar.app 本身动态计算的,这是脚本无法通过请求 Calendar.app 获得的虚拟近似值

Instead, your script itself should compute what the Calendar.app computes.相反,您的脚本本身应该计算 Calendar.app 计算的内容。 Knowing the start date of the first instance and the recurrence period, the script should use the normal addition and multiplication operations .知道一审的开始日期和重复周期,脚本应该使用正常的加法和乘法运算

For example,例如,

(startDate of N-th instance) = (startDate of 1-st instance) + N* (period of 1-st instance). (第 N 个实例的开始日期)=(第 1 个实例的开始日期)+ N*(第 1 个实例的周期)。

Or,或者,

(endDate of N-th instance) = (endDate of 1-st instance) + N* (period of 1-st instance) (第 N 个实例的结束日期)=(第 1 个实例的结束日期)+ N*(第 1 个实例的周期)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM