问题描述
我使用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:
Reading从文件的iCal信息,使iCal事件
例如:所以我只是有日期的列表,但我甚至不能得到原始与出得到一个无效的日期错误运行。
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对象像日期2013年7月4日6:00 PM
,但公认的格式依赖于系统preferences选择的区域或日期格式。
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
这篇关于的AppleScript打造集iCal事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!