Getting timezone from phone number

1,190 views
Skip to first unread message

Ran Mochary

unread,
May 1, 2012, 6:47:18 AM5/1/12
to libphonenumber-discuss
Hi,

In my app I wish to extract a unix/olson timezone id from the phone
number. (e.g. "America/Los Angeles")
This can be a good addition to the geocoder library.
What would be a good way to perform this?

Thanks,
Ran

David Cantrell

unread,
May 3, 2012, 8:00:54 AM5/3/12
to libphonenum...@googlegroups.com
See PhoneNumberOfflineGeocoder, from which you can get the name of the
area code. But once you've got that, figuring out that, for example,
Hastings in the UK is in timezone Europe/London would, rightly be the
responsibility of some other library.

Unfortunately I don't think that library exists.

--
David Cantrell | semi-evolved ape-thing

There are many different types of sausages. The best are
from the north of England. The wurst are from Germany.
-- seen in alt.2eggs...

Lara Rennie

unread,
May 3, 2012, 8:10:19 AM5/3/12
to libphonenum...@googlegroups.com
Hey,

This is a nice idea. We don't have time to work on this soon, but we
will definitely look at adding it for future versions of the library.

I don't know if it would be possible to use the Google Maps API to get
the longitude/latitude of a particular location? And then use
something like http://www.earthtools.org/webservices.htm#timezone to
get the timezone in the meantime?

Lara

2012/5/3 David Cantrell <da...@cantrell.org.uk>:

Ran Mochary

unread,
May 7, 2012, 4:07:16 AM5/7/12
to libphonenum...@googlegroups.com
Thanks for your suggestions.

I was looking for an offline solution that can work in a mobile app, so felt like google library would be a good place for it.
My current requirement covers only the USA, so I created a simple Java class holding a static map of area code to  time zone, according to the following list: http://fonality.com/trixbox/node/34134

I will appreciate if you decide to implement this feature as a google library, and will be happy to contribute if possible.
BTW, at the moment the earth tools API provides timezone info only for European locations.
I assume this can be augmented by alternative web services.

Ran

g1smd

unread,
May 9, 2012, 3:44:33 PM5/9/12
to libphonenumber-discuss
For some types of numbers, it is impossible to deduce a time
zone. For mobile numbers and non-geographic numbers in
countries with multiple time zones this is a major problem.

It's one thing getting the Standard time zone for some place,
adding the DST offset is quite another. The changeover dates
vary from year to year and the northern hemisphere adds an
hour during the months that the southern hemisphere takes
an hour off.
http://www.timeanddate.com/time/dst/2012a.html
http://www.timeanddate.com/time/dst/2012b.html

Ran Mochary

unread,
May 10, 2012, 5:07:45 AM5/10/12
to libphonenum...@googlegroups.com
Thanks for noting this limitation.
I am looking for a reasonable compromise like the offline geocoder mentioned below, so can accept this limitation.
Also, DST info is not an issue for me, as I am only interested in getting the olson id (for example America/New_York). 
Once having the olson id, current systems can deduce DST offset for a specific date (Java and Obj-C).

Ran
Reply all
Reply to author
Forward
0 new messages