Calendar - Creating an Event


tell application "Calendar"
	tell calendar "Test"
		set cur_date to (current date)
		set cur_date to "Monday, September 2, 2013 3:15:30 PM"
		make new event at end with properties {description:"Event Description", summary:"Event Name", location:"Event Location", start date:cur_date as date, filepath:"/users/temp/desktop/test.app"}
	end tell
end tell

Objective:

  • create an event with a specific date
  • add an open a file alert to that event that open 0 minutes before

Issues:

  • specifying a date gives “Can’t make “Monday, September 2, 2013 3:15:30 PM” into type date.”

any hep would be appreciated.

I don’t think you can use ‘as date’

Maybe:

date cur_date

even without it I still get

Calendar got an error: Can’t make “Monday, September 2, 2013 3:15:30 PM” into type date.

change cur_date as string to date cur_date

Edited: I meant change cur_date as date to date cur_date

tell application "Calendar"
	tell calendar "Test"
		set cur_date to (current date)
		set cur_date to "Monday, September 2, 2013 3:15:30 PM"
		make new event at end with properties {description:"Event Description", summary:"Event Name", location:"Event Location", start date:cur_date, filepath:"/users/temp/desktop/test.app"}
	end tell
end tell

same issue

Hi slashdot,

You didn’t do what I said. That’s why you ended up with the full date. When you compile the script it changes your short dates to full dates. That’s why I put the string date into a variable. I’m thinking about later on also.

gl,
kel

Hi. The filepath belongs to the alarm, not the event. Additionally, it might be nice to use something other than “cur_date” as a variable for a date that isn’t the current date. :slight_smile:


set alarmDate to date "Monday, September 2, 2013 3:15:30 PM"

tell application "Calendar" to tell calendar "Test" to tell (make event with properties {summary:"Whatever", start date:alarmDate})
	make open file alarm with properties {trigger date:alarmDate, filepath:(((path to desktop) as text) & "test.app")'s POSIX path}
end tell

thanks that works :slight_smile: