2011-05-06 31 views
4

我遍歷iCal中的所有事件以僅獲取今天的事件,但我不認爲這是有效的。有沒有一種功能/方法只能獲得今天的活動?從iCal獲取今日活動與AppleScript

tell application "iCal" 
    tell calendar "Lotus Notes" 
     set today to (current date) 
     set this_year to year of today 
     set this_month to month of today 
     set this_day to day of today 

     repeat with c in every event 
      set d to start date of c 
      set the_year to year of d 
      set the_month to month of d 
      set the_day to day of d 
      if (the_year = this_year) and (the_month = this_month) and (the_day = this_day) then 
       show c 
      end if 
     end repeat 
    end tell 
end tell 

回答

7

試試這個:

set {year:y, month:m, day:d} to current date 
set str to (m as string) & " " & (d as string) & " " & (y as string) 
set today to date str 
set tomorrow to today + 60 * 60 * 24 

tell application "iCal" 
    tell calendar "Lotus Notes" 
     set curr to every event whose start date is greater than or equal to today ¬ 
      and start date is less than or equal to tomorrow 
    end tell 
end tell 
+1

這不會得到任何重複事件,上早日首先定義,今天發生的。看起來像一個棘手的問題,看着其他答案,人們似乎在使用http://hasseg.org/icalBuddy/ – Von 2011-10-06 14:06:51