如何用AppleScript为无日期提醒设置仅今日日期(不含时间)
用AppleScript为提醒设置无时间的今日全天截止日期
你需要的是给无截止日期的提醒设置全天截止日期(仅显示今日日期,无任何时间标识),默认的current date会包含当前时分秒,直接清零时间会得到午夜标识,通过以下方式可实现需求:
修正后的AppleScript代码
tell application "Reminders" -- 构造仅含今日日期的全天日期对象 set today to current date set hours of today to 0 set minutes of today to 0 set seconds of today to 0 repeat with r in every reminder if due date of r is missing value then set due date of r to today end if end repeat end tell
代码说明
- 先通过
current date获取当前日期时间,再将时、分、秒全部清零,得到今日0点的日期对象 - Reminders会自动识别这类时间为0的日期对象为全天截止日期,在UI中只会显示日期,不会出现任何时间标识(包括午夜)
- 遍历所有提醒,仅给无截止日期的提醒设置这个全天日期
原代码失效原因
- 直接使用
current date会包含当前的时分秒,设置后提醒会显示具体时间 - 单独设置时间为0但未正确构造全天日期对象时,Reminders会显示为午夜时间,而非隐藏时间的全天模式
内容的提问来源于stack exchange,提问作者Daniel
相关产品推荐
相关产品推荐

