【发布时间】:2015-01-03 10:45:34
【问题描述】:
伙计们,
我是 AppleScript 新手。我想将许多事件添加到 iCal 日历。所有事件都应该是全天事件,因此它们没有开始时间或持续时间。我在文本文件中有日期,每行一个。但我只是将它们作为字符串复制到脚本中。这是我的代码(缩短了日期列表):
set input to "03.01.2015
16.01.2015
30.01.2015
13.02.2015
20.11.2015
04.12.2015
18.12.2015"
repeat with datum in paragraphs of input
tell application "Calendar" to tell calendar "Müll"
make new event with properties {start date:date datum, summary:"Gargabe", allday event:true}
end tell
end repeat
我从 Apple 脚本编辑器得到的错误是
Invalid date and time date (item 1 of every paragraph of 03.01.2015
16.01.2015
30.01.2015
...
现在,我运行的是英文版 OS X,但我的语言环境设置为德国。 (很想发布相应首选项屏幕的屏幕截图,但在 stackoverflow 上没有足够的声誉。)
有人提示我这里出了什么问题吗? 提前非常感谢!
(顺便说一句,在 OS X 10.10.1 上运行。)
【问题讨论】:
-
根据this related question,Applescript 期望看到的日期完全取决于您在 Macintosh 系统偏好设置中选择的区域或日期格式。 “
16.01.2015”格式是否正确? -
是的,系统偏好设置显示 dd.mm.yyyy 是它可以理解的正确日期。
标签: applescript icalendar