I sometimes want to create an event in iCal from a date that appears on a web page I'm viewing in Safari. Using Automator, I created a Service to do just that.

Here's how:

Launch Automator

Select Service from the Choose a Template for your Workflow sheet.

Set the drop-downs at the top of the Untitled service to 'Service receives selected' [dates] 'in' [Safari].

Drag a Run AppleScript action to the top of the Untitled service.

Replace the template text in the Run AppleScript action with the following:

on run {input, parameters}
set eventDate to date (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
tell application "iCal"
activate
tell calendar "Home"
set newEvent to make new event at end of events with properties {summary:eventSummary, url:eventUrl, start date:eventDate, end date:eventDate + 30 * minutes}
show newEvent
end tell
end tell
end run

In the AppleScript text above, replace Home with the name of the iCal calendar that you want to receive the new events.

Save the service as New iCal Event from Date (or whatever you wish to call it).

You should now be able to select something resembling a date/time in Safari and run this Service via either the contextual menu or the Services menu. Note that the data detector for dates seems a bit more liberal than AppleScript at parsing dates, so you may sometimes get an AppleScript error when running this service.

You can retrieve the dates from text selected in Safari or any other application that supports Services using an Automator action posted on www.macosxautomation.com. There are two text filtering actions here:http://www.macosxautomation.com/services/download/actions.html Get URLs from Text and Get Dates from Text. Retrieved dates will be in UNIX format which can be converted to AppleScript date records fairly easily. -- ENJOY!

Unfortunately, this Automator Service doesn't work if the date doesn't include a year. You will get an error. If you use the "Get Dates from Text" action from www.macosxautomation.com you will at least get an iCal event, but the date will be wrong, and you'll get a year like "0002".

That's cool, I finally have my right click "add date to iCal" from a web page, it's very unfortunate it only works if there is a year in the date though...There might be a way to default to the current year within the Script so at least you don't get an error.
It'd be nice though Apple builds this feature into Safari as it is in Mail. The Automator Service version of the Date pattern detector apparently doesn't work as well as the one in Mail.

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 "ebay.co" 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)
else
set eventDate to date (input as text)
end if
tell application "iCal"
activate
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