google_tz 0.3.0 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Histroy.md +6 -0
- data/README.md +39 -4
- data/lib/google_tz/version.rb +1 -1
- data/spec/lib/google_tz_spec.rb +10 -13
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2c96f0de679da3f4f300107e23d8a4351971bb31
|
4
|
+
data.tar.gz: ffe0469a19a1047fcf52f87a50f3e438dce9b39e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 19f36000ca8569149be3f26b9d19710b4243991c6b42b8e021f004865537380bded5c4de9abf9cc5df64a21af1cadf3d0c0bbed4b869dcbb19d1d6aeddf2e167
|
7
|
+
data.tar.gz: edc79ae204d1938ede820068b4cc81f50ed6f56b492fa7b5c07f4d1c03c7232b664de7afd0065a71720c221cc90c2b5811e14d95980fd79999313c8bc700a386
|
data/Histroy.md
CHANGED
data/README.md
CHANGED
@@ -5,12 +5,47 @@
|
|
5
5
|
|
6
6
|
gem install google_tz
|
7
7
|
|
8
|
-
## Usage
|
9
|
-
|
8
|
+
## Usage
|
9
|
+
|
10
|
+
### Require
|
10
11
|
require 'google_tz'
|
11
12
|
|
13
|
+
### Lookup
|
14
|
+
|
12
15
|
# Lookup timezone information on a location using latitude and longitude.
|
13
16
|
GoogleTZ.lookup(39.7392, -104.9847)
|
14
17
|
|
15
|
-
# Lookup timezone
|
16
|
-
GoogleTZ.lookup(39.7392, -104.9847, timestamp: 1377891332, language: "es")
|
18
|
+
# Lookup timezone information on a location using latitude, longitude, timestamp, and language
|
19
|
+
GoogleTZ.lookup(39.7392, -104.9847, timestamp: 1377891332, language: "es")
|
20
|
+
|
21
|
+
### Response
|
22
|
+
|
23
|
+
# Seeing if the Google API call was a success.
|
24
|
+
resp = GoogleTZ.lookup(39.7392, -104.9847)
|
25
|
+
resp.success?
|
26
|
+
=> true
|
27
|
+
|
28
|
+
# Getting data out of the lookup response object.
|
29
|
+
resp = GoogleTZ.lookup(39.7392, -104.9847)
|
30
|
+
resp.data
|
31
|
+
=> {"dstOffset"=>3600, "rawOffset"=>-25200, "status"=>"OK", "timeZoneId"=>"America/Denver", "timeZoneName"=>"Mountain Daylight Time"}
|
32
|
+
|
33
|
+
# Get daylight saving time offset
|
34
|
+
resp.dst_offset
|
35
|
+
=> 3600
|
36
|
+
|
37
|
+
# Get the raw time zone offset
|
38
|
+
resp.raw_offset
|
39
|
+
=> -25200
|
40
|
+
|
41
|
+
# Get the status of the google api call
|
42
|
+
resp.status
|
43
|
+
=> "OK"
|
44
|
+
|
45
|
+
# Get the time zone id
|
46
|
+
resp.timezone_id
|
47
|
+
=> "America/Denver"
|
48
|
+
|
49
|
+
# Get the time zone name
|
50
|
+
resp.timezone_name
|
51
|
+
=> "Mountain Daylight Time"
|
data/lib/google_tz/version.rb
CHANGED
data/spec/lib/google_tz_spec.rb
CHANGED
@@ -3,8 +3,9 @@ require 'spec_helper'
|
|
3
3
|
describe 'GoogleTZ' do
|
4
4
|
describe 'lookup' do
|
5
5
|
it 'fetches timezone info for a given latitude, longitude' do
|
6
|
+
GoogleTZ.should_receive(:lookup).and_return(GoogleTZAPI::Response.new("{\n \"dstOffset\" : 3600,\n \"rawOffset\" : -25200,\n \"status\" : \"OK\",\n \"timeZoneId\" : \"America/Denver\",\n \"timeZoneName\" : \"Mountain Daylight Time\"\n}\n"))
|
6
7
|
resp = GoogleTZ.lookup(39.7392, -104.9847)
|
7
|
-
|
8
|
+
|
8
9
|
resp.success?.should == true
|
9
10
|
resp.status.should == 'OK'
|
10
11
|
resp.dst_offset.should == 3600
|
@@ -14,19 +15,15 @@ describe 'GoogleTZ' do
|
|
14
15
|
end
|
15
16
|
|
16
17
|
it 'fetches timezone info when given optional arguments' do
|
18
|
+
GoogleTZ.should_receive(:lookup).and_return(GoogleTZAPI::Response.new("{\n \"dstOffset\" : 3600,\n \"rawOffset\" : -25200,\n \"status\" : \"OK\",\n \"timeZoneId\" : \"America/Denver\",\n \"timeZoneName\" : \"Rocky Mountain Sommerzeit\"\n}\n"))
|
17
19
|
resp = GoogleTZ.lookup(39.7392, -104.9847, timestamp: 1377891332, sensor: false, language: "de")
|
18
20
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
21
|
+
resp.success?.should == true
|
22
|
+
resp.status.should == 'OK'
|
23
|
+
resp.dst_offset.should == 3600
|
24
|
+
resp.raw_offset.should == -25200
|
25
|
+
resp.timezone_id.should == "America/Denver"
|
26
|
+
resp.timezone_name.should == "Rocky Mountain Sommerzeit"
|
25
27
|
end
|
26
28
|
end
|
27
|
-
end
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
"{\n \"dstOffset\" : 3600,\n \"rawOffset\" : -25200,\n \"status\" : \"OK\",\n \"timeZoneId\" : \"America/Denver\",\n \"timeZoneName\" : \"Hora de verano de Montaña\"\n}\n"
|
32
|
-
'{\n \"dstOffset\" : 3600,\n \"rawOffset\" : -25200,\n \"status\" : \"OK\",\n \"timeZoneId\" : \"America/Denver\",\n \"timeZoneName\" : \"Hora de verano de Monta\\xC3\\xB1a\"\n}\n'
|
29
|
+
end
|