1

Iam working on a Rails app where I want to get timezone from latitude and longitude. I searched for this on stackoverflow and found this link as the best way to do this.

I installed both the gems geokit and timezone and tried to implement the same in my console:

require 'geokit'
require 'timezone'
res = Geokit::Geocoders::GoogleGeocoder.geocode('140 Market St, San Francisco, CA')
timezone = Timezone::Zone.new(:latlon => res.ll)

But I get this error:

ArgumentError: wrong number of arguments (1 for 2)

I checked the documentation for Timezone. They ask to get a username by signing up. But I have not received any activation mail yet. Can someone please suggest some solution for this.

Thanks in advance.

Community
  • 1
  • 1
Swati Aggarwal
  • 1,265
  • 3
  • 19
  • 34

1 Answers1

0

It looks like the call Timezone::Zone.new(:latlon => res.ll) does not work (at least I got the same error). I think it is due to changes in format of res.ll value returned from Google. But this call should do the job:

Timezone::Zone.new(lat: res.lat, lon: res.lng)

However, first make sure that you create an account with GeoNames and active it here. You also have to create and configure an initializer for timezone gem. The later is described over here: timezone/lib/timezone/configure.rb