Is it possible to add events into iCal that happened in the past - i’m not sure if i have the date format wrong, but the events always go into the current time cell.
Could someone give me an example of the correct date & time format iCal uses please ?
It depends on how you’re getting your dates. If you’re getting your dates as text, then you could coerce the date to AppleScript date. For instance:
set d to "7/14/06 18:00"
set as_date to date d
You could also set the date relative to some date like the current date. For instance the following will create an event in iCal 24 hours from the current date:
set cur_date to (current date)
set tomorrow_date to cur_date + 1 * days
tell application "iCal"
set this_cal to first calendar
set new_event to ¬
make new event at end of events of this_cal with properties ¬
{summary:"Test Event", start date:tomorrow_date}
end tell
With your date manipulation method. I’m correct in thinking i could make it a bit more dynamic by taking the current date, and subtracting that, fooling iCal into thinking it was the 1st of the month, midnight (or there abouts)… ?
I’m not sure if this works in Tiger, because I think they changed what is returned for months from a constant like ‘July’ to the month number like ‘7’, but you can try this to get the first day of the current month:
set this_month to (month of (current date)) as string
set first_day to (date this_month)
If ‘month of (current date)’ returns a number then something like this works:
set m to 7
set d to ((m as string) & "/1")
date d
Edited: I forgot this one:
set t to "1"
date t
You can try experimenting with the various coercions. If you want the dates to turn out relative to current date, then you need to set it as text first as I did. Otherwise, when you compile something like:
date “1”
the compiler will automatically coerce “1” to the first day of the current month and it won’t be dynamic.