Pick of the Week - Nov 10 [Show all picks]
Path Finder 5 - A feature-laden Finder replacement
Submit Hint Search The Forums LinksStatsPollsFAQHeadlinesRSS
12,000 hints and counting!

10.6: Create iCal event from dates in Safari Apps
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:
  1. Launch Automator
  2. Select Service from the Choose a Template for your Workflow sheet.
  3. Set the drop-downs at the top of the Untitled service to 'Service receives selected' [dates] 'in' [Safari].
  4. Drag a Run AppleScript action to the top of the Untitled service.
  5. 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
  6. In the AppleScript text above, replace Home with the name of the iCal calendar that you want to receive the new events.
  7. 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.
    •    
  • Currently 3.75 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (4 votes cast)
 
[4,040 views]  

10.6: Create iCal event from dates in Safari | 3 comments | Create New Account
Click here to return to the '10.6: Create iCal event from dates in Safari' hint
The following comments are owned by whomever posted them. This site is not responsible for what they say.
10.6: Create iCal event from dates in Safari
Authored by: mr. applescript on Mon, Oct 12 2009 at 9:42AM PDT
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!

[ Reply to This | # ]
10.6: Create iCal event from dates in Safari
Authored by: paul7 on Sat, Oct 24 2009 at 11:00PM PDT
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".

[ Reply to This | # ]
10.6: Create iCal event from dates in Safari
Authored by: Jaime Gago on Wed, Jan 20 2010 at 2:01PM PST
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.
Edited on Wed, Jan 20 2010 at 2:03PM PST by Jaime Gago


[ Reply to This | # ]