A script I made for time tracking with TextWrangler.
(*
Script for TextWrangler
paste iCal Event based on current text selection in TextWrangler.
For use with iCal template script.
Save text file as .ics and it can be imported or
opened by Outlook and other Calendar Apps supporting iCal standard.
Reference: http://tools.ietf.org/html/rfc5545
RFC5545 Internet Calendaring and Scheduling Core Object Specification (iCalendar)
Ian Stevenson 111202
Disclaimer: code provided without warranty
example iCal event format
BEGIN:VEVENT
UID:uid1@example.com
DTSTAMP:19970714T170000Z
ORGANIZER;CN=John Doe:MAILTO:john.doe@example.com
DTSTART:19970714T170000Z
DTEND:19970715T035959Z
SUMMARY:Bastille Day Party
END:VEVENT
*)
tell application "TextWrangler"
activate
-- store selected text
copy contents of selection to temp
-- all this just to ISO UTC dateformat: 19970714T170000Z
set cd to (current date) - (time to GMT) --convert current time to GMT
set {year:y, month:m, day:d, hours:h, minutes:min, seconds:s} to cd as date
if h < 10 then
set h to "0" & h as string
end if
if min < 10 then
set min to "0" & min as string
end if
if s < 10 then
set s to "0" & s as string
end if
set UTC to (((((y * 10000 + m * 100 + d) as string) & "T" & h as string) & min as string) & s as string) & "Z"
-- make another time one minute on as end time for event
set UTC1 to (((((y * 10000 + m * 100 + d) as string) & "T" & h as string) & min + 1 as string) & s as string) & "Z"
-- paste iCal elements into document
set contents of clipboard 1 to "BEGIN:VEVENT" & return
select clipboard 1
paste
set contents of clipboard 1 to "UID:" & "UID" & UTC & "@audile.net" & return
select clipboard 1
paste
set contents of clipboard 1 to "DTSTAMP:" & UTC & return
select clipboard 1
paste
set contents of clipboard 1 to "DTSTART:" & UTC & return
select clipboard 1
paste
set contents of clipboard 1 to "DTEND:" & UTC1 & return
select clipboard 1
paste
-- use clipboard contents as subject field
set contents of clipboard 1 to "SUMMARY:" & temp & return
select clipboard 1
paste
-- make more verbose body text
set contents of clipboard 1 to "DESCRIPTION: " & temp & " entered at " & (current date) & " by textwrangler script." & return
select clipboard 1
paste
set contents of clipboard 1 to "END:VEVENT" & return
select clipboard 1
paste
end tell