用于创建设置 iCal 事件的 Applescript [英] Applescript to create set iCal events
问题描述
我使用 iCal 来跟踪我的班次,事件信息与三种标准班次类型相同,我通常复制并粘贴它们,因为没有模式.
I use iCal to kept track of my shifts, the event info is the same three standard shift types and I usually copy and paste them as there's no pattern.
我正在尝试确定是否可以使用 Applescript 来加快速度.我想输入一些日期和班次类型让 Applescript 创建事件.
I'm trying to work out if theres away using Applescript to speed it up. I'd like to input some dates and shift type have Applescript create the events.
我试着看看我是否可以为每个班次类型调整这个:
I tried to see if I could adapt this for each shift type:
例如,我只有一个日期列表,但我什至无法在没有收到无效日期错误的情况下运行原始文件.
eg so I just had a list of dates but I couldn't even get the original to run with out getting an invalid date error.
推荐答案
你可以创建一个类似于 date "7/4/2013 6:00 PM"
的日期对象,但是可以识别的格式取决于在系统偏好设置中选择的区域或日期格式.
You can create a date object with something like date "7/4/2013 6:00 PM"
, but the recognized formats depend on the region or date formats selected in System Preferences.
set input to "7/4 night
7/5 day"
set y to year of (current date)
set text item delimiters to " "
repeat with l in paragraphs of input
set d to text item 1 of l
set type to text item 2 of l
if type is "night" then
set sd to date (d & "/" & y & " 5:00 PM")
set ed to date (d & "/" & y & " 11:00 PM")
else if type is "day" then
set sd to date (d & "/" & y & " 9:00 AM")
set ed to date (d & "/" & y & " 5:00 PM")
end if
tell application "Calendar" to tell calendar "test"
make new event with properties {start date:sd, end date:ed, summary:"work"}
end tell
end repeat
这篇关于用于创建设置 iCal 事件的 Applescript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!