ziptz 2.1.14 → 3.0.4
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/Gemfile.lock +49 -50
- data/LICENSE +1 -1
- data/README.md +102 -23
- data/Rakefile +0 -6
- data/data/tz.data +0 -0
- data/data/tzm.data +3 -0
- data/lib/ziptz.rb +32 -46
- data/spec/ziptz_spec.rb +2 -2
- metadata +4 -5
- data/data/dst.data +0 -41692
- data/lib/zip_code.rb +0 -68
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 544975d57a57d2b3e5f9457a1338f22e80d72d48efcca6b9d549aa56f77345dd
|
|
4
|
+
data.tar.gz: 4e5d4966e2c9271e34b83e20fe82759a6f186da621da6c85423b38670f225349
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c5f7ad01c1abc535025818c64c4d15fa6c5928f89829836828cdac76a6410c99397dfe961a9d9ef4ef2a2c92a54c872846dd10d43ef4952f7c322bbb11ee814f
|
|
7
|
+
data.tar.gz: 66a0fa89d92520277307d774192b1b18d5e6c7a1740c8bb7af00b78f4439d4548b9b6c36c534e6e4c9c3c54cc87af485be0fd8106a8bf0babe9f0955b3c42e00
|
data/Gemfile.lock
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
ziptz (
|
|
4
|
+
ziptz (3.0.2)
|
|
5
5
|
|
|
6
6
|
GEM
|
|
7
7
|
remote: https://rubygems.org/
|
|
8
8
|
specs:
|
|
9
|
-
activemodel (6.
|
|
10
|
-
activesupport (= 6.
|
|
11
|
-
activerecord (6.
|
|
12
|
-
activemodel (= 6.
|
|
13
|
-
activesupport (= 6.
|
|
14
|
-
activesupport (6.
|
|
9
|
+
activemodel (6.1.3.1)
|
|
10
|
+
activesupport (= 6.1.3.1)
|
|
11
|
+
activerecord (6.1.3.1)
|
|
12
|
+
activemodel (= 6.1.3.1)
|
|
13
|
+
activesupport (= 6.1.3.1)
|
|
14
|
+
activesupport (6.1.3.1)
|
|
15
15
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
|
16
|
-
i18n (>=
|
|
17
|
-
minitest (
|
|
18
|
-
tzinfo (~>
|
|
19
|
-
zeitwerk (~> 2.
|
|
20
|
-
ast (2.4.
|
|
16
|
+
i18n (>= 1.6, < 2)
|
|
17
|
+
minitest (>= 5.1)
|
|
18
|
+
tzinfo (~> 2.0)
|
|
19
|
+
zeitwerk (~> 2.3)
|
|
20
|
+
ast (2.4.2)
|
|
21
21
|
byebug (11.1.3)
|
|
22
22
|
coderay (1.1.3)
|
|
23
|
-
concurrent-ruby (1.1.
|
|
23
|
+
concurrent-ruby (1.1.8)
|
|
24
24
|
diff-lcs (1.4.4)
|
|
25
|
-
ffi (1.
|
|
25
|
+
ffi (1.15.0)
|
|
26
26
|
formatador (0.2.5)
|
|
27
27
|
guard (2.16.2)
|
|
28
28
|
formatador (>= 0.2.4)
|
|
@@ -38,81 +38,80 @@ GEM
|
|
|
38
38
|
guard (~> 2.1)
|
|
39
39
|
guard-compat (~> 1.1)
|
|
40
40
|
rspec (>= 2.99.0, < 4.0)
|
|
41
|
-
i18n (1.8.
|
|
41
|
+
i18n (1.8.10)
|
|
42
42
|
concurrent-ruby (~> 1.0)
|
|
43
|
-
io-console (0.5.
|
|
44
|
-
irb (1.
|
|
43
|
+
io-console (0.5.9)
|
|
44
|
+
irb (1.3.5)
|
|
45
45
|
reline (>= 0.1.5)
|
|
46
|
-
listen (3.
|
|
46
|
+
listen (3.5.1)
|
|
47
47
|
rb-fsevent (~> 0.10, >= 0.10.3)
|
|
48
48
|
rb-inotify (~> 0.9, >= 0.9.10)
|
|
49
49
|
lumberjack (1.2.8)
|
|
50
50
|
method_source (1.0.0)
|
|
51
|
-
minitest (5.14.
|
|
51
|
+
minitest (5.14.4)
|
|
52
52
|
mysql2 (0.5.3)
|
|
53
53
|
nenv (0.3.0)
|
|
54
54
|
notiffany (0.1.3)
|
|
55
55
|
nenv (~> 0.1)
|
|
56
56
|
shellany (~> 0.0)
|
|
57
|
-
parallel (1.
|
|
58
|
-
parser (
|
|
57
|
+
parallel (1.20.1)
|
|
58
|
+
parser (3.0.1.0)
|
|
59
59
|
ast (~> 2.4.1)
|
|
60
|
-
pry (0.
|
|
60
|
+
pry (0.14.1)
|
|
61
61
|
coderay (~> 1.1)
|
|
62
62
|
method_source (~> 1.0)
|
|
63
63
|
rainbow (3.0.0)
|
|
64
|
-
rake (13.0.
|
|
64
|
+
rake (13.0.3)
|
|
65
65
|
rb-fsevent (0.10.4)
|
|
66
66
|
rb-inotify (0.10.1)
|
|
67
67
|
ffi (~> 1.0)
|
|
68
|
-
regexp_parser (1.
|
|
69
|
-
reline (0.
|
|
68
|
+
regexp_parser (2.1.1)
|
|
69
|
+
reline (0.2.5)
|
|
70
70
|
io-console (~> 0.5)
|
|
71
|
-
rexml (3.2.
|
|
71
|
+
rexml (3.2.5)
|
|
72
72
|
rspec (3.10.0)
|
|
73
73
|
rspec-core (~> 3.10.0)
|
|
74
74
|
rspec-expectations (~> 3.10.0)
|
|
75
75
|
rspec-mocks (~> 3.10.0)
|
|
76
|
-
rspec-core (3.10.
|
|
76
|
+
rspec-core (3.10.1)
|
|
77
77
|
rspec-support (~> 3.10.0)
|
|
78
|
-
rspec-expectations (3.10.
|
|
78
|
+
rspec-expectations (3.10.1)
|
|
79
79
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
80
80
|
rspec-support (~> 3.10.0)
|
|
81
|
-
rspec-mocks (3.10.
|
|
81
|
+
rspec-mocks (3.10.2)
|
|
82
82
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
83
83
|
rspec-support (~> 3.10.0)
|
|
84
|
-
rspec-support (3.10.
|
|
85
|
-
rubocop (
|
|
84
|
+
rspec-support (3.10.2)
|
|
85
|
+
rubocop (1.13.0)
|
|
86
86
|
parallel (~> 1.10)
|
|
87
|
-
parser (>=
|
|
87
|
+
parser (>= 3.0.0.0)
|
|
88
88
|
rainbow (>= 2.2.2, < 4.0)
|
|
89
|
-
regexp_parser (>= 1.8)
|
|
89
|
+
regexp_parser (>= 1.8, < 3.0)
|
|
90
90
|
rexml
|
|
91
|
-
rubocop-ast (>=
|
|
91
|
+
rubocop-ast (>= 1.2.0, < 2.0)
|
|
92
92
|
ruby-progressbar (~> 1.7)
|
|
93
|
-
unicode-display_width (>= 1.4.0, <
|
|
94
|
-
rubocop-ast (1.1
|
|
93
|
+
unicode-display_width (>= 1.4.0, < 3.0)
|
|
94
|
+
rubocop-ast (1.4.1)
|
|
95
95
|
parser (>= 2.7.1.5)
|
|
96
|
-
rubocop-performance (1.
|
|
97
|
-
rubocop (>=
|
|
96
|
+
rubocop-performance (1.11.1)
|
|
97
|
+
rubocop (>= 1.7.0, < 2.0)
|
|
98
98
|
rubocop-ast (>= 0.4.0)
|
|
99
|
-
rubocop-rspec (
|
|
100
|
-
rubocop (~> 0
|
|
101
|
-
rubocop-ast (>=
|
|
102
|
-
ruby-progressbar (1.
|
|
99
|
+
rubocop-rspec (2.3.0)
|
|
100
|
+
rubocop (~> 1.0)
|
|
101
|
+
rubocop-ast (>= 1.1.0)
|
|
102
|
+
ruby-progressbar (1.11.0)
|
|
103
103
|
shellany (0.0.1)
|
|
104
|
-
thor (1.0
|
|
105
|
-
thread_safe (0.3.6)
|
|
104
|
+
thor (1.1.0)
|
|
106
105
|
tty-cursor (0.7.1)
|
|
107
106
|
tty-spinner (0.9.3)
|
|
108
107
|
tty-cursor (~> 0.7)
|
|
109
|
-
tzinfo (
|
|
110
|
-
|
|
111
|
-
unicode-display_width (
|
|
112
|
-
zeitwerk (2.4.
|
|
108
|
+
tzinfo (2.0.4)
|
|
109
|
+
concurrent-ruby (~> 1.0)
|
|
110
|
+
unicode-display_width (2.0.0)
|
|
111
|
+
zeitwerk (2.4.2)
|
|
113
112
|
|
|
114
113
|
PLATFORMS
|
|
115
|
-
|
|
114
|
+
x86_64-darwin-19
|
|
116
115
|
|
|
117
116
|
DEPENDENCIES
|
|
118
117
|
activerecord
|
|
@@ -131,4 +130,4 @@ DEPENDENCIES
|
|
|
131
130
|
ziptz!
|
|
132
131
|
|
|
133
132
|
BUNDLED WITH
|
|
134
|
-
2.
|
|
133
|
+
2.2.16
|
data/LICENSE
CHANGED
data/README.md
CHANGED
|
@@ -4,9 +4,15 @@
|
|
|
4
4
|
[](https://rubygems.org/gems/ziptz/)
|
|
5
5
|
[](https://github.com/infused/ziptz)
|
|
6
6
|
|
|
7
|
-
Get time zone
|
|
7
|
+
Get time zone, daylight saving time, and base offset for any US ZIP code.
|
|
8
8
|
|
|
9
|
-
<i>ZIP codes are up to date as of <b>
|
|
9
|
+
<i>ZIP codes are up to date as of <b>June 2021</b>.</i>
|
|
10
|
+
|
|
11
|
+
## Compatibility
|
|
12
|
+
|
|
13
|
+
Ziptz is tested to work with the following versions of Ruby:
|
|
14
|
+
|
|
15
|
+
* Ruby 2.3.x, 2.4.x, 2.5.x, 2.6.x, 2.7.x, 3.0.x, and TruffleRuby
|
|
10
16
|
|
|
11
17
|
## Installation
|
|
12
18
|
|
|
@@ -24,7 +30,7 @@ Get the time zone name for any ZIP code:
|
|
|
24
30
|
|
|
25
31
|
Get the time zone offset for any ZIP code:
|
|
26
32
|
|
|
27
|
-
z.time_zone_offset('97213') #=> -
|
|
33
|
+
z.time_zone_offset('97213') #=> -28800
|
|
28
34
|
|
|
29
35
|
<em>Note that offsets do not include daylight saving time.</em>
|
|
30
36
|
|
|
@@ -34,32 +40,105 @@ Determine if the ZIP code uses Daylight Saving Time:
|
|
|
34
40
|
|
|
35
41
|
Get all the zip codes in a time zone:
|
|
36
42
|
|
|
37
|
-
z.zips('Pacific/
|
|
43
|
+
z.zips('Pacific/Chuuk') #=> ["96942", "96943"]
|
|
38
44
|
|
|
39
45
|
|
|
40
46
|
## Supported Time Zones
|
|
41
47
|
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
48
|
+
* America/Adak
|
|
49
|
+
* America/Anchorage
|
|
50
|
+
* America/Boise
|
|
51
|
+
* America/Chicago
|
|
52
|
+
* America/Denver
|
|
53
|
+
* America/Detroit
|
|
54
|
+
* America/Indiana/Indianapolis
|
|
55
|
+
* America/Indiana/Knox
|
|
56
|
+
* America/Indiana/Marengo
|
|
57
|
+
* America/Indiana/Petersburg
|
|
58
|
+
* America/Indiana/Tell_City
|
|
59
|
+
* America/Indiana/Vevay
|
|
60
|
+
* America/Indiana/Vincennes
|
|
61
|
+
* America/Indiana/Winamac
|
|
62
|
+
* America/Juneau
|
|
63
|
+
* America/Kentucky/Louisville
|
|
64
|
+
* America/Kentucky/Monticello
|
|
65
|
+
* America/Los_Angeles
|
|
66
|
+
* America/Menominee
|
|
67
|
+
* America/Metlakatla
|
|
68
|
+
* America/New_York
|
|
69
|
+
* America/Nome
|
|
70
|
+
* America/North_Dakota/Beulah
|
|
71
|
+
* America/North_Dakota/Center
|
|
72
|
+
* America/North_Dakota/New_Salem
|
|
73
|
+
* America/Phoenix
|
|
74
|
+
* America/Puerto_Rico
|
|
75
|
+
* America/Sitka
|
|
76
|
+
* America/St_Thomas
|
|
77
|
+
* America/Yakutat
|
|
78
|
+
* Pacific/Chuuk
|
|
79
|
+
* Pacific/Guam
|
|
80
|
+
* Pacific/Honolulu
|
|
81
|
+
* Pacific/Kosrae
|
|
82
|
+
* Pacific/Kwajalein
|
|
83
|
+
* Pacific/Majuro
|
|
84
|
+
* Pacific/Pago_Pago
|
|
85
|
+
* Pacific/Palau
|
|
86
|
+
* Pacific/Pohnpei
|
|
87
|
+
* Pacific/Saipan
|
|
88
|
+
* Pacific/Wake
|
|
56
89
|
|
|
57
90
|
<em>Note that APO/FPO zip codes will not return a known time zone offset.</em>
|
|
58
91
|
|
|
59
|
-
##
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
92
|
+
## Prefer raw data?
|
|
93
|
+
|
|
94
|
+
If you would prefer raw data instead of a gem, see my [ZIP Code Time Zones](https://us-west-2.console.aws.amazon.com/dataexchange/home#/products/prodview-4vcapflqwntdw) product on AWS Data Exchange to subscribe.
|
|
95
|
+
|
|
96
|
+
## Version 3 breaking changes
|
|
97
|
+
|
|
98
|
+
* APO, DPO, and FPO zip codes are no longer included, because they are non-geographic.
|
|
99
|
+
* Time zone offsets are now specified in seconds instead of hours.
|
|
100
|
+
* Time zone are now more granular. The full list of time zones is:
|
|
101
|
+
* America/Adak
|
|
102
|
+
* America/Anchorage
|
|
103
|
+
* America/Boise
|
|
104
|
+
* America/Chicago
|
|
105
|
+
* America/Denver
|
|
106
|
+
* America/Detroit
|
|
107
|
+
* America/Indiana/Indianapolis
|
|
108
|
+
* America/Indiana/Knox
|
|
109
|
+
* America/Indiana/Marengo
|
|
110
|
+
* America/Indiana/Petersburg
|
|
111
|
+
* America/Indiana/Tell_City
|
|
112
|
+
* America/Indiana/Vevay
|
|
113
|
+
* America/Indiana/Vincennes
|
|
114
|
+
* America/Indiana/Winamac
|
|
115
|
+
* America/Juneau
|
|
116
|
+
* America/Kentucky/Louisville
|
|
117
|
+
* America/Kentucky/Monticello
|
|
118
|
+
* America/Los_Angeles
|
|
119
|
+
* America/Menominee
|
|
120
|
+
* America/Metlakatla
|
|
121
|
+
* America/New_York
|
|
122
|
+
* America/Nome
|
|
123
|
+
* America/North_Dakota/Beulah
|
|
124
|
+
* America/North_Dakota/Center
|
|
125
|
+
* America/North_Dakota/New_Salem
|
|
126
|
+
* America/Phoenix
|
|
127
|
+
* America/Puerto_Rico
|
|
128
|
+
* America/Sitka
|
|
129
|
+
* America/St_Thomas
|
|
130
|
+
* America/Yakutat
|
|
131
|
+
* Pacific/Chuuk
|
|
132
|
+
* Pacific/Guam
|
|
133
|
+
* Pacific/Honolulu
|
|
134
|
+
* Pacific/Kosrae
|
|
135
|
+
* Pacific/Kwajalein
|
|
136
|
+
* Pacific/Majuro
|
|
137
|
+
* Pacific/Pago_Pago
|
|
138
|
+
* Pacific/Palau
|
|
139
|
+
* Pacific/Pohnpei
|
|
140
|
+
* Pacific/Saipan
|
|
141
|
+
* Pacific/Wake
|
|
63
142
|
|
|
64
143
|
## Version 2 breaking changes
|
|
65
144
|
|
|
@@ -81,7 +160,7 @@ Time zone names now reflect standard tz-database names.
|
|
|
81
160
|
|
|
82
161
|
## License
|
|
83
162
|
|
|
84
|
-
Copyright (c) 2015-
|
|
163
|
+
Copyright (c) 2015-2021 Keith Morrison <<keithm@infused.org>>
|
|
85
164
|
|
|
86
165
|
Permission is hereby granted, free of charge, to any person
|
|
87
166
|
obtaining a copy of this software and associated documentation
|
data/Rakefile
CHANGED
data/data/tz.data
CHANGED
|
Binary file
|
data/data/tzm.data
ADDED
data/lib/ziptz.rb
CHANGED
|
@@ -1,41 +1,33 @@
|
|
|
1
1
|
require 'yaml'
|
|
2
|
+
require 'zlib'
|
|
2
3
|
|
|
3
4
|
class Ziptz
|
|
4
|
-
VERSION = '
|
|
5
|
-
|
|
6
|
-
TZ_INFO = {
|
|
7
|
-
'0' => {name: 'APO/FPO (time zone unknown)', offset: 0},
|
|
8
|
-
'4' => {name: 'America/Puerto_Rico', offset: -4},
|
|
9
|
-
'5' => {name: 'America/New_York', offset: -5},
|
|
10
|
-
'6' => {name: 'America/Chicago', offset: -6},
|
|
11
|
-
'7' => {name: 'America/Denver', offset: -7},
|
|
12
|
-
'8' => {name: 'America/Los_Angeles', offset: -8},
|
|
13
|
-
'9' => {name: 'America/Anchorage', offset: -9},
|
|
14
|
-
'10' => {name: 'Pacific/Honolulu', offset: -10},
|
|
15
|
-
'11' => {name: 'Pacific/Pago_Pago', offset: -11},
|
|
16
|
-
'13' => {name: 'Pacific/Majuro', offset: 12},
|
|
17
|
-
'14' => {name: 'Pacific/Guam', offset: 10},
|
|
18
|
-
'15' => {name: 'Pacific/Palau', offset: 9},
|
|
19
|
-
'16' => {name: 'Pacific/Pohnpei', offset: 11},
|
|
20
|
-
'AZ' => {name: 'America/Phoenix', offset: -7},
|
|
21
|
-
'AD' => {name: 'America/Adak', offset: -10}
|
|
22
|
-
}.freeze
|
|
5
|
+
VERSION = '3.0.4'.freeze
|
|
23
6
|
|
|
24
7
|
def time_zone_name(zip)
|
|
25
|
-
|
|
8
|
+
tz_info = time_zone_info(zip)
|
|
9
|
+
return unless tz_info
|
|
10
|
+
|
|
11
|
+
tz_info[:tz]
|
|
26
12
|
end
|
|
27
13
|
|
|
28
14
|
def time_zone_offset(zip)
|
|
29
|
-
|
|
30
|
-
|
|
15
|
+
tz_info = time_zone_info(zip)
|
|
16
|
+
return unless tz_info
|
|
17
|
+
|
|
18
|
+
tzm_info = tzm[tz_info[:tz]]
|
|
19
|
+
tzm_info[:offset] && tzm_info[:offset].to_i
|
|
31
20
|
end
|
|
32
21
|
|
|
33
22
|
def time_zone_uses_dst?(zip)
|
|
34
|
-
|
|
23
|
+
tz_info = time_zone_info(zip)
|
|
24
|
+
return unless tz_info
|
|
25
|
+
|
|
26
|
+
tz_info[:dst]
|
|
35
27
|
end
|
|
36
28
|
|
|
37
29
|
def zips(tz_name)
|
|
38
|
-
|
|
30
|
+
tz.select { |_, v| v[:tz].downcase == tz_name.downcase }.keys
|
|
39
31
|
end
|
|
40
32
|
|
|
41
33
|
def inspect
|
|
@@ -44,24 +36,20 @@ class Ziptz
|
|
|
44
36
|
|
|
45
37
|
protected
|
|
46
38
|
|
|
47
|
-
def
|
|
48
|
-
@
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
def dst
|
|
52
|
-
@dst ||= load_dst_data
|
|
39
|
+
def tzm
|
|
40
|
+
@tzm ||= load_tzm_data
|
|
53
41
|
end
|
|
54
42
|
|
|
55
|
-
def
|
|
56
|
-
tz
|
|
43
|
+
def tz
|
|
44
|
+
@tz ||= load_tz_data
|
|
57
45
|
end
|
|
58
46
|
|
|
59
47
|
def time_zone_info(zip)
|
|
60
|
-
|
|
48
|
+
tz[zip.to_s.slice(0, 5)]
|
|
61
49
|
end
|
|
62
50
|
|
|
63
|
-
def
|
|
64
|
-
|
|
51
|
+
def tzm_data_path
|
|
52
|
+
File.join(File.dirname(__FILE__), '..', 'data', 'tzm.data')
|
|
65
53
|
end
|
|
66
54
|
|
|
67
55
|
def tz_data_path
|
|
@@ -69,20 +57,18 @@ class Ziptz
|
|
|
69
57
|
end
|
|
70
58
|
|
|
71
59
|
def load_tz_data
|
|
72
|
-
File.
|
|
73
|
-
|
|
74
|
-
|
|
60
|
+
uncompressed = Zlib::Inflate.inflate(File.read(tz_data_path, encoding: 'ASCII-8BIT'))
|
|
61
|
+
uncompressed.each_line.with_object({}) do |line, data|
|
|
62
|
+
zip, tz, dst = line.strip.split(':')
|
|
63
|
+
data[zip] = {tz: tz, dst: dst == '1'}
|
|
75
64
|
end
|
|
76
65
|
end
|
|
77
66
|
|
|
78
|
-
def
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
File.foreach(dst_data_path).with_object({}) do |line, data|
|
|
84
|
-
zip, dst = line.strip.split('=')
|
|
85
|
-
data[zip] = dst == '1'
|
|
67
|
+
def load_tzm_data
|
|
68
|
+
uncompressed = Zlib::Inflate.inflate(File.read(tzm_data_path, encoding: 'ASCII-8BIT'))
|
|
69
|
+
uncompressed.each_line.with_object({}) do |line, data|
|
|
70
|
+
tz, offset = line.strip.split(':')
|
|
71
|
+
data[tz] = {offset: offset}
|
|
86
72
|
end
|
|
87
73
|
end
|
|
88
74
|
end
|