Address Book Plug-Ins: Age
The script – I don't remember where I found it – now looks like this:
{quote}
<pre>
(* This script adds a popup to birthday field that shows the persons age *)
using terms from application "Address Book"
on calculateAge(bdate)
set age to ((year of (current date)) - 1 - (year of bdate))
if (month of (current date) > (month of bdate)) then
set age to age + 1
else if (month of (current date) = (month of bdate)) then
if (day of (current date) ≥ (day of bdate)) then
set age to age + 1
end if
end if
return age
end calculateAge
on action property
return "birth date"
end action property
on action title for p with e
set userAge to calculateAge(e)
return (name of p & " is " & (userAge as string)) & " years old"
end action title
on should enable action for p with e
return true
end should enable action
on perform action for p with e
set userAge to calculateAge(e)
display dialog (name of p & " is " & (userAge as string)) ¬
& " years old"
end perform action
end using terms from
</pre>
{quote}
MacBook Pro 13" 2.26GHz (June 2009), Mac OS X (10.6.1), Time Capsule 500GB, Airport Express, iPod shuffle 512MB, iPod nano 8GB