iCal: Liste der heutigen Events

Gibt eine Liste der Events aus, die am heutigen Tag beginnen und auch enden

getThisDaysEvents_List(“Hubi”)

on getThisDaysEvents_List(calendarname)

tell application “iCal”

set startdate to (current date) – ((minutes of (current date)) * 60) – ((hours of (current date)) * 60 * 60) – (seconds of (current date))

set enddate to startdate + (3600 * 24)

tell calendar calendarname

set eventnames to summary of every event whose start date > startdate and end date < enddate

set event_starts to start date of every event whose start date > startdate and end date < enddate

end tell

set myoutput to “”

repeat with i from 1 to count of eventnames

set myoutput to myoutput & “” & (characters 1 through -4 of (time string of item i of event_starts)) & “  ” & item i of eventnames & return

end repeat

set myoutput to my BubbleSort(every paragraph of myoutput)

set AppleScript‘s text item delimiters to return

set myoutput to myoutput as text

set AppleScript‘s text item delimiters to “”

return “Events @ ” & date string of (current date) & “:” & return & myoutput

end tell

end getThisDaysEvents_List

on BubbleSort(theList)

if class of theList is list then

set theSize to length of theList

repeat with i from 1 to theSize

repeat with j from 2 to (theSizei + 1)

if ((item (j – 1) of theList) > (item j of theList)) then

set temp to (item (j – 1) of theList)

set (item (j – 1) of theList) to (item j of theList)

set (item j of theList) to temp

end if

end repeat

end repeat

return theList

else

return false

end if

end BubbleSort