Forum: Ruby on Rails Getting from geolocation (lat/long) to Time.zone

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
29a2920b953591c4e75fdf796418d41d?d=identicon&s=25 Tom Karlo (tomkarlo)
on 2008-12-09 17:30
(Received via mailing list)
Has anyone found a good solution for setting the Rails Time.zone from
a lat/long pair? I've been wrestling around with this.

The closest I can come is using the geonames API, but the problem is I
haven't found anything that will do a decent job of converting from
their time zone namespace over to the Rails time zone namespace.

There are some hacks out there that use the UTC or GMT offset and
convert by finding a time zone with the same UTC offset between the
Geonames and Rails time zone sets. Unfortunately, it's not a very good
hack because it ignores the fact that you might have multiple time
zones of different countries within the same UTC offset but with
different policies around daylight savings time. No to mention that
it's a little wonky when someone enters a location near Capetown,
South Africa and the routine assigns them to the time zone for
Helsinki, Finland.

Is there anything that will do a better job of mapping, or am I just
using the wrong method entirely (i.e. is there a way to do this
without using the Geonames service at all?) It seems to me this is
probably something that has to be a service type situation, since
making a static mapping of all the time zones and then maintaining it
is probably impractical for a small site.

Thanks,
Tom
16b26104470ae1b64958f3caa836c193?d=identicon&s=25 Danny Burkes (dburkes)
on 2008-12-09 19:04
> Has anyone found a good solution for setting the Rails Time.zone from
> a lat/long pair? I've been wrestling around with this.

You need a lat/long to timezone database- many are available, I've had
good luck with http://www.zipinfo.com/products/z5ll/z5ll.htm
16b26104470ae1b64958f3caa836c193?d=identicon&s=25 Danny Burkes (dburkes)
on 2008-12-09 19:06
> You need a lat/long to timezone database- many are available, I've had
> good luck with http://www.zipinfo.com/products/z5ll/z5ll.htm

Forgot to mention- combine this database with something like
http://zipcodesearch.rubyforge.org/, and you're good to go.

- D
29a2920b953591c4e75fdf796418d41d?d=identicon&s=25 Tom Karlo (tomkarlo)
on 2008-12-09 20:53
(Received via mailing list)
I'm already using the geonames API... unless there's a service out
there that returns names matching those in Time.zone it seems like
this would leave me with exactly the same problem.

On Dec 9, 1:06 pm, Danny Burkes <rails-mailing-l...@andreas-s.net>
This topic is locked and can not be replied to.