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

A script to display local times in Address Book Apps
Here is is my first Address Book plug-in attempt; I was inspired by the other hints from this site. Actually, this is my first AppleScript as well -- I mostly just copy and paste from other scripts. As seen in the screenshot, this script will display the local time for a contact when you control-click on a special Timezone field.

The first thing you need to do is create the special Timezone field to hold the GMT offset. The best thing I came up with is to add the Related Names field (Card -> Add Field -> Related Names), and then apply a custom label of Timezone to the Friend field (you can remove Assistant, if you want) . I also added this field to the template (Card -> Add Field -> Edit Template) to make it available to all contacts. To use the script, first edit a contact's record, and enter their offset from GMT in the Timezone field -- for example, Eastern Standard Time is currently -5 hours from GMT. Then control-click on the Timezone field, and you'll see the local time in the pop-up menu. The script does not take daylight savings time into account. That, as they say, is left as an excercise to the reader.

It would be great to add a lookup service to convert zip code to time zone, removing the need for the Timezone field. But I just did a quick hack. I hope this helps someone ... I know the hints on this site have helped me, the good ones and the bad!
    •    
  • Currently 1.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (1 vote cast)
 
[4,793 views]  

A script to display local times in Address Book | 2 comments | Create New Account
Click here to return to the 'A script to display local times in Address Book' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
A script to display local times in Address Book
Authored by: miles_thatsme on Mar 14, '05 01:55:18PM
You really do need a lookup to make this useful, I think. A good place to start might be http://www.timeanddate.com. It seems like you can append the name of any city to the following to get the current time zone:

http://www.timeanddate.com/worldclock/results.html?query=

You then just need to extract the text so that it appears in address book's menu...

[ Reply to This | # ]
A script to display local times in Address Book
Authored by: edchrist on Mar 15, '05 08:32:17AM
you can get the timezone based on Longitude of an address and csgnetwork does lookup of zipcode that returns the Longitude which I used to create this timezone look up function:


on gettz(addrzip)
	set cmdscrpt to "echo `curl http://www.csgnetwork.com/cgi-bin/zipcodes.cgi -s -d Zipcode=" & addrzip & " -G|grep Longitude|cut -f 6 -d '>'|cut -f 1 -d '<'`"
	do shell script cmdscrpt
	set lat to the result as real
	if lat > 0 then
		set tznew to (lat + 7.5) / 15 as integer
	else
		set tznew to (lat - 7.5) / 15 as integer
	end if
	return tznew
end gettz


[ Reply to This | # ]