Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Click here to return to the '10.6: Create iCal event from dates in Safari' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
10.6: Create iCal event from dates in Safari
Authored by: PizzaCake on Jun 23, '11 05:42:00AM
Thanks, I had to amend the code to handle the odd situation where dates and times on eBay are not space separated and setting an alarm.

on run {input, parameters}
	set eventDate to (input as text)
	tell application "Safari"
		set currentTab to current tab of first window
		set eventSummary to name of currentTab
		set eventUrl to URL of currentTab
	end tell
	if eventUrl contains "" then
		set eventDateCleaned to items 1 thru 6 of eventDate as text
		set eventDateCleaned to eventDateCleaned & (items 8 thru 12 of eventDate as text)
		set eventDateCleaned to eventDateCleaned & space & (items 13 thru 20 of eventDate as text)
		set eventDate to date (eventDateCleaned)
		set eventDate to date (input as text)
	end if
	tell application "iCal"
		tell calendar "Home"
			set newEvent to make new event at end of events with properties {summary:eventSummary, url:eventUrl, start date:eventDate - 30 * minutes, end date:eventDate}
			tell newEvent
				make new sound alarm at end of sound alarms with properties {trigger interval:0, sound name:"Submarine"}
			end tell
			show newEvent
		end tell
	end tell
end run

[ Reply to This | # ]