Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
--- This script prompts you for a calendar and then adds up
--- the durations of all it's events
set _seconds to 0
tell application "Calendar"
set _calendars to {}
repeat with _cal in every calendar
copy (name of _cal) to end of _calendars
end repeat
set _selected to choose from list _calendars
if _selected is false then return
tell calendar (_selected as string)
repeat with e in every event
tell e
set _seconds to _seconds + (end date - start date)
end tell
end repeat
end tell
end tell
set _hours to _seconds / 3600
set _result to do shell script "python -c 'import datetime, sys; print datetime.timedelta(seconds=int(sys.argv[1]))' " & _seconds
display dialog _result with title "Total hours: " & _hours
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.