us_time_zones 1.0.4 → 2.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +2 -0
- data/dumpfile.rb +70 -0
- data/lib/us_time_zones/tz_coord_files/alaska.rb +1 -0
- data/lib/us_time_zones/tz_coord_files/central.rb +1 -0
- data/lib/us_time_zones/tz_coord_files/eastern.rb +1 -0
- data/lib/us_time_zones/tz_coord_files/hawaii_aleutian_1.rb +1 -0
- data/lib/us_time_zones/tz_coord_files/hawaii_aleutian_2.rb +1 -0
- data/lib/us_time_zones/tz_coord_files/mountain.rb +1 -0
- data/lib/us_time_zones/tz_coord_files/pacific.rb +1 -0
- data/lib/us_time_zones/version.rb +1 -1
- data/lib/us_time_zones.rb +43 -6
- data/us_time_zones-1.0.10.gem +0 -0
- data/us_time_zones-1.0.5.gem +0 -0
- data/us_time_zones-1.0.6.gem +0 -0
- data/us_time_zones-1.0.7.gem +0 -0
- data/us_time_zones-1.0.8.gem +0 -0
- data/us_time_zones-1.0.9.gem +0 -0
- data/us_time_zones-2.0.0.gem +0 -0
- data/us_time_zones-2.0.1.gem +0 -0
- data/us_time_zones-2.0.3.gem +0 -0
- data/us_time_zones-2.0.4.gem +0 -0
- data/us_time_zones-2.0.5.gem +0 -0
- data/us_time_zones.gemspec +3 -3
- metadata +35 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 200bafa2eeccde3b26ae3fe0d96e51070aca3cc0
|
4
|
+
data.tar.gz: 01e334a5756cb3257413d21c8bf87b217b36b1c9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1d353f64e31054f7580773fe5d382e82e17cb4c4f8811ed674e13a3528eaa580176a6b793a9f5c4392a749986e095555ddb4d3783eae0817aa0d524a624d3a58
|
7
|
+
data.tar.gz: 6fce5f524970e651dc43f91c2608f2bf2f08738818bb169c7a1f3cc089c3e90f1eda9b55059e7dd2783580e9ad55cd496b2d5b043234e5cfb26d9ffeb0c88cfd
|
data/Gemfile
CHANGED
data/dumpfile.rb
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
class USTZones
|
2
|
+
def self.getZone(lat, lng)
|
3
|
+
if lat.class != String
|
4
|
+
lat = lat.to_s
|
5
|
+
end
|
6
|
+
if lng.class != String
|
7
|
+
lng = lng.to_s
|
8
|
+
end
|
9
|
+
url = "https://maps.googleapis.com/maps/api/geocode/json?latlng=#{lat},#{lng}&key=AIzaSyBgUT0t3K3y9cKJgITa8X1O7uGYjguNZT4"
|
10
|
+
response = HTTParty.get(url).to_json
|
11
|
+
response = JSON.parse(response)
|
12
|
+
|
13
|
+
if response["results"] == []
|
14
|
+
p "Error"
|
15
|
+
elsif response["results"][0]["formatted_address"].include?("USA")
|
16
|
+
p "You're in the USA"
|
17
|
+
else
|
18
|
+
p "You're not in the USA"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
# 53.37734988622845, -169.504588281682
|
24
|
+
class TZtest
|
25
|
+
def self.test(lat, lng)
|
26
|
+
if HAWAII_ALEUTIAN.include?([lat,lng])
|
27
|
+
p "includes bla bla!"
|
28
|
+
else
|
29
|
+
p "does not include bla bla bla!"
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
# Version with determining if it's in the US first using Google Maps API (I don't want to have to rely on the GMaps API call, though, because there are limits to how much you can call it and you have to pay for it beyond that limit)
|
35
|
+
class TZ
|
36
|
+
def self.whichTZ?(point)
|
37
|
+
alaska = GeoRuby::SimpleFeatures::Polygon.from_coordinates([ALASKA])
|
38
|
+
hawaii_aleutian_1 = GeoRuby::SimpleFeatures::Polygon.from_coordinates([HAWAII_ALEUTIAN_1])
|
39
|
+
hawaii_aleutian_2 = GeoRuby::SimpleFeatures::Polygon.from_coordinates([HAWAII_ALEUTIAN_2])
|
40
|
+
central = GeoRuby::SimpleFeatures::Polygon.from_coordinates([CENTRAL])
|
41
|
+
eastern = GeoRuby::SimpleFeatures::Polygon.from_coordinates([EASTERN])
|
42
|
+
pacific = GeoRuby::SimpleFeatures::Polygon.from_coordinates([PACIFIC])
|
43
|
+
mountain = GeoRuby::SimpleFeatures::Polygon.from_coordinates([MOUNTAIN])
|
44
|
+
|
45
|
+
pointObject = GeoRuby::SimpleFeatures::Point.from_x_y(point[0], point[1])
|
46
|
+
url = "https://maps.googleapis.com/maps/api/geocode/json?latlng=#{point[0].to_s},#{point[1].to_s}&key=AIzaSyBgUT0t3K3y9cKJgITa8X1O7uGYjguNZT4"
|
47
|
+
response = HTTParty.get(url).to_json
|
48
|
+
response = JSON.parse(response)
|
49
|
+
|
50
|
+
if response["results"] == []
|
51
|
+
return "Error"
|
52
|
+
elsif response["results"][0]["formatted_address"].include?("USA")
|
53
|
+
if eastern.contains_point?(pointObject)
|
54
|
+
return "US Eastern Time Zone"
|
55
|
+
elsif central.contains_point?(pointObject)
|
56
|
+
return "US Central Time Zone"
|
57
|
+
elsif pacific.contains_point?(pointObject)
|
58
|
+
return "US Pacific Time Zone"
|
59
|
+
elsif mountain.contains_point?(pointObject)
|
60
|
+
return "US Mountain Time Zone"
|
61
|
+
elsif hawaii_aleutian_1.contains_point?(pointObject) || hawaii_aleutian_2.contains_point?(pointObject)
|
62
|
+
return "US Hawaii-Aleutian Time Zone"
|
63
|
+
elsif alaska.contains_point?(pointObject)
|
64
|
+
return "US Alaska Time Zone"
|
65
|
+
end
|
66
|
+
else
|
67
|
+
return "Unable to determine time zone for coordinates outside the US"
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
ALASKA = [[69.64689539964057, -141.0003734649445], [60.30631867821476, -141.0018653561777], [61.42720433364058, -135.7055632172227], [56.39003591645753, -129.3586712966009], [54.75949426375769, -128.4510401396097], [53.79952645749127, -129.111374808], [54.33843772981551, -131.5848461295318], [54.43881303867774, -134.0170156166531], [58.11576979898622, -139.3107470441809], [58.79607884274877, -144.9597346954218], [57.24886342643417, -150.8064844716893], [52.94170085173271, -161.4589706760086], [51.24721161290269, -169.5074725499983], [55.77860927282759, -169.4977353571379], [57.8144578619313, -172.8575040402843], [62.65517793204116, -175.1125481830799], [65.2356252122485, -169.0800362682199], [66.36654061775553, -168.8625353818834], [67.60932460468874, -168.2121104560134], [70.77799914205067, -165.8890939886333], [72.48035914583002, -158.4664966359572], [71.60610819450777, -146.0508618994126], [70.55938868042529, -140.7614211553691], [69.71582432321841, -140.9581210440876], [69.71581984712684, -140.9581271835287], [69.6469397358079, -141.0003767988982]]
|