proper date format to enter an event in iCal

Hi
I get my work schedule on an excel sheet.
I would like to make a calendar and then post whether I am working or not as seperate events in iCal. I have a script that makes a calendar and gets the info from numbers (opened the excel sheet in numbers) but I cannot figure out what format to use to get iCal to accept my date as a date.

My computer is set for Canadian date standard.

here the function that I have (can send the complete if you need it)

-------------------start script---------------
on addEventToCalendar(workDay, whichDay, theName, monthNumber, theYear)
set eventString to “”
if workDay is “O” then
set eventString to “Day Off”
else if workDay is “R” then
set eventString to “Regular Day”
else if workDay is “A” then
set eventString to “9:00 Start”
else if workDay is “L” then
set eventString to “Holiday”
end if
set theDate to theYear & “-” & monthNumber & “-” & whichDay as string
–set theDate to myDate as date
display dialog theDate as string
– set theDate to “Sunday,November 13, 2011 8:01:48 PM” as date
tell application “iCal”
tell calendar “My Calendar”
make new event at end with properties {summary:eventString, start date:date theDate}
end tell
end tell
display dialog monthNumber
end addEventToCalendar

Hi,

try this


on addEventToCalendar(workDay, whichDay, theName, monthNumber, theYear)
	set eventString to ""
	if workDay is "O" then
		set eventString to "Day Off"
	else if workDay is "R" then
		set eventString to "Regular Day"
	else if workDay is "A" then
		set eventString to "9:00 Start"
	else if workDay is "L" then
		set eventString to "Holiday"
	end if
	tell (current date) to set theDate to it - (its time)
	tell theDate to set {day, year, its month, day} to {whichDay, theYear, monthNumber, whichDay}
	display dialog theDate as string
	tell application "iCal"
		tell calendar "My Calendar"
			make new event at end with properties {summary:eventString, start date:theDate}
		end tell
	end tell
	display dialog monthNumber
end addEventToCalendar


actually the variable theName isn’t used at all in the handler

Thanks so Much Stefen
Can’t say I understand what the ‘it’ is all about but I am happy it is working
I guess that is the difference between people who know how scripting works, and those of us who just muddle through different scripts and change them to do what we want!

tell (current date) to set theDate to it - (its time)

does the same as

set theDate to (current date) - (current date's time)

but it avoids to call current date twice