Class: Timez::Location

Inherits:
Object
  • Object
show all
Defined in:
lib/timez/location.rb

Class Method Summary collapse

Class Method Details

.get_time(lat, lng, key) ⇒ Object



4
5
6
7
# File 'lib/timez/location.rb', line 4

def self.get_time(lat, lng, key)
  response = HTTP.get($URL, :params => { :lat => lat, :lng => lng, :key => key, :format => "json" }).to_s
  JSON[response]
end

.get_time_json(lat, lng, key) ⇒ Object



24
25
26
# File 'lib/timez/location.rb', line 24

def self.get_time_json(lat, lng, key)
  get_time(lat, lng, key)
end

.get_time_timestamp(lat, lng, key) ⇒ Object



19
20
21
22
# File 'lib/timez/location.rb', line 19

def self.get_time_timestamp(lat, lng, key)
  hash = get_time(lat, lng, key)
  hash['timestamp']
end

.get_time_utc(lat, lng, key) ⇒ Object



9
10
11
12
# File 'lib/timez/location.rb', line 9

def self.get_time_utc(lat, lng, key)
  hash = get_time(lat, lng, key)
  Time.at(hash['timestamp']).utc
end

.get_time_zone(lat, lng, key) ⇒ Object



14
15
16
17
# File 'lib/timez/location.rb', line 14

def self.get_time_zone(lat, lng, key)
  hash = get_time(lat, lng, key)
  Time.at(hash['timestamp'])
end