Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/date/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Date AppleScript:时间格式更改+;日历事件_Date_Calendar_Applescript - Fatal编程技术网

Date AppleScript:时间格式更改+;日历事件

Date AppleScript:时间格式更改+;日历事件,date,calendar,applescript,Date,Calendar,Applescript,我正在尝试创建一个脚本来记录我的当前时间和完成时间 执行特定操作,让他们使用此时间变量发送电子邮件,并使用此时间变量创建日历事件: set FinsihDate to (current date) + 10 * hours + 30 * minutes set startingDate to (current date) set plistR to {FinsihDate:FinsihDate, starteddate:current date} tell application "Sys

我正在尝试创建一个脚本来记录我的当前时间和完成时间 执行特定操作,让他们使用此时间变量发送电子邮件,并使用此时间变量创建日历事件:

set FinsihDate to (current date) + 10 * hours + 30 * minutes
set startingDate to (current date)


set plistR to {FinsihDate:FinsihDate, starteddate:current date}

tell application "System Events"
    set plistf to make new property list file ¬
        with properties {name:"~/Desktop/MY_Time.plist"}

    set plistf's value to plistR
end tell



## Email
property lastWindowID : missing value
tell application "Mail"
    set windowIDs to id of windows
    if windowIDs does not contain lastWindowID then
        set newMessage to make new outgoing message with properties {subject:"Started early", content:"Hi ..., \n \nI started early today : " & (current date) & ", I will leave at " & FinsihDate & "\n \nKind Regards,\nKevin " & return & return}
        tell newMessage
            set visible to true
            make new to recipient at end of to recipients with properties {name:"Name", address:"@apple.com"}
        end tell
        activate
        set lastWindowID to id of window 1
    else
        tell window id lastWindowID
            set visible to false
            set visible to true
        end tell
        activate
    end if
end tell



set startDate to date (current date)
set endDate to date FinsihDate

tell application "Calendar"
    tell (first calendar whose name is "calendar")
        make new event at end of events with properties {summary:"Work", start date:startDate, end date:endDate, description:"ITS Fraud Prevention", location:"Apple"}
    end tell
end tell
  • 时间格式

    电子邮件上的时间格式是“2018年6月4日星期一14:25:57”,而我只想要14:25

  • 我试过这个:

    set myTime to (time string of (current date)) + 10 * hours + 30 * minutes
    
    结果:错误“无法将\“14:27:02\”转换为类型编号。“编号-1700” 从“14:27:02”到数字

  • 历法
  • 创建日历事件时,我遇到了此错误

    错误“无法获取日期(日期\“2018年6月4日星期一14:29:34\”) 编号-1728自日期起(日期“2018年6月4日星期一14:29:34”)


    感谢您逐项列出您遇到并希望修复的单个错误。这使得我更容易阅读这个问题并确定它是我想要回答的问题,因为我实际上根本不需要测试您的脚本,因为我可以立即看到问题是什么:

    ① 你的括号放错地方了。更改此项:

    set myTime to (time string of (current date)) + 10 * hours + 30 * minutes
    
    为此:

    set myTime to time string of ((current date) + 10 * hours + 30 * minutes)
    
    set startDate to (current date)
    set endDate to FinsihDate
    
    ② 该错误表示您试图获取类型为
    date
    的变量,然后将其再次声明为类型
    date
    。AppleScript不喜欢这样

    更改这两行:

    set startDate to date (current date)
    set endDate to date FinsihDate
    
    为此:

    set myTime to time string of ((current date) + 10 * hours + 30 * minutes)
    
    set startDate to (current date)
    set endDate to FinsihDate
    
    我还没有测试脚本的其余部分

    另外,您拼写错误了变量名
    FinsihDate
    (我想应该是
    FinishDate
    )。然而,在整个脚本中,它始终拼写错误,因此没有任何实际区别