|
set today to current date |
|
set hours of today to 0 |
|
set minutes of today to 0 |
|
set tomorrow to today + 1 * days |
|
set yesterday to today - (1 * days) |
|
|
|
set yesterdaysName to the date string of yesterday |
|
set todaysName to the date string of today |
|
|
|
on buildTimeString(theDate) |
|
-- Get the "hour" |
|
set timeStr to time string of theDate |
|
set Pos to offset of ":" in timeStr |
|
set theHour to characters 1 thru (Pos - 1) of timeStr as string |
|
set timeStr to characters (Pos + 1) through end of timeStr as string |
|
|
|
-- Get the "minute" |
|
set Pos to offset of ":" in timeStr |
|
set theMin to characters 1 thru (Pos - 1) of timeStr as string |
|
set timeStr to characters (Pos + 1) through end of timeStr as string |
|
|
|
--Get "AM or PM" |
|
set Pos to offset of " " in timeStr |
|
set theSfx to characters (Pos + 1) through end of timeStr as string |
|
|
|
return (theHour & ":" & theMin & " " & theSfx) as string |
|
end buildTimeString |
|
|
|
on eventsForDay(theDay) |
|
set theEvents to {} |
|
tell application "Calendar" |
|
repeat with c in (every calendar) |
|
repeat with e in ((every event in c) whose (start date) is greater than or equal to theDay and (start date) is less than theDay + (1 * days) and (start date) is not in (excluded dates)) |
|
if (allday event of e) then |
|
set end of theEvents to ("All Day: " & (summary of e)) |
|
else |
|
set startDate to start date of e |
|
set timeString to buildTimeString(startDate) of me |
|
set end of theEvents to (timeString & ": " & (summary of e)) |
|
end if |
|
end repeat |
|
end repeat |
|
end tell |
|
return theEvents |
|
end eventsForDay |
|
|
|
|
|
tell application "Notes" |
|
|
|
set todaysEvents to eventsForDay(today) of me |
|
|
|
if length of todaysEvents is 0 then |
|
set noteBody to "<h2>No Events</h2>" |
|
else |
|
set noteBody to "<h2>Events</h2><ul>" |
|
repeat with theEvent in todaysEvents |
|
set noteBody to noteBody & "<li>" & theEvent & "</li>" |
|
end repeat |
|
set noteBody to noteBody & "</ul>" |
|
end if |
|
|
|
set noteBody to noteBody & "<br><h2>Tasks</h2>" |
|
|
|
move note yesterdaysName to folder "Archive" |
|
|
|
set noteTitle to "<h1>" & todaysName & "</h1><br>" |
|
make new note at folder "Projects" with properties {name:" ", body:noteTitle & noteBody} |
|
|
|
end tell |