ziptz 2.1.10 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +69 -58
- data/LICENSE +1 -1
- data/README.md +96 -18
- 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 -41696
- 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: 58a543bdf4161509318a1d76b85fcda2feaa38c1c109cbb306360a1d770d4caa
|
4
|
+
data.tar.gz: a8ea39f8f78aba709e3c3a08916d56a64c70f7add692e5af4f6b77fc612649ad
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3970fc1eb3951eb742c348936012ac61124583f89d7758bdcd159c1ec8de66352387201bcedce8141e929046be78c7bb3e78bb497523e0965a5b47a6ad08153e
|
7
|
+
data.tar.gz: 070d0bb85eac2a9256447000df5e9cd5d929a29aa34025b48a8c6967a54bbe95c284227541ff12d5e223414a23b70366a8aa6099e684174f17afda130170a4d1
|
data/Gemfile.lock
CHANGED
@@ -1,30 +1,30 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
ziptz (2.1.
|
4
|
+
ziptz (2.1.14)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
8
8
|
specs:
|
9
|
-
activemodel (6.0.
|
10
|
-
activesupport (= 6.0.
|
11
|
-
activerecord (6.0.
|
12
|
-
activemodel (= 6.0.
|
13
|
-
activesupport (= 6.0.
|
14
|
-
activesupport (6.0.
|
9
|
+
activemodel (6.0.3.4)
|
10
|
+
activesupport (= 6.0.3.4)
|
11
|
+
activerecord (6.0.3.4)
|
12
|
+
activemodel (= 6.0.3.4)
|
13
|
+
activesupport (= 6.0.3.4)
|
14
|
+
activesupport (6.0.3.4)
|
15
15
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
16
16
|
i18n (>= 0.7, < 2)
|
17
17
|
minitest (~> 5.1)
|
18
18
|
tzinfo (~> 1.1)
|
19
|
-
zeitwerk (~> 2.2)
|
20
|
-
ast (2.4.
|
21
|
-
byebug (11.
|
22
|
-
coderay (1.1.
|
23
|
-
concurrent-ruby (1.1.
|
24
|
-
diff-lcs (1.
|
25
|
-
ffi (1.
|
19
|
+
zeitwerk (~> 2.2, >= 2.2.2)
|
20
|
+
ast (2.4.1)
|
21
|
+
byebug (11.1.3)
|
22
|
+
coderay (1.1.3)
|
23
|
+
concurrent-ruby (1.1.7)
|
24
|
+
diff-lcs (1.4.4)
|
25
|
+
ffi (1.13.1)
|
26
26
|
formatador (0.2.5)
|
27
|
-
guard (2.16.
|
27
|
+
guard (2.16.2)
|
28
28
|
formatador (>= 0.2.4)
|
29
29
|
listen (>= 2.7, < 4.0)
|
30
30
|
lumberjack (>= 1.0.12, < 2.0)
|
@@ -38,67 +38,78 @@ GEM
|
|
38
38
|
guard (~> 2.1)
|
39
39
|
guard-compat (~> 1.1)
|
40
40
|
rspec (>= 2.99.0, < 4.0)
|
41
|
-
i18n (1.
|
41
|
+
i18n (1.8.5)
|
42
42
|
concurrent-ruby (~> 1.0)
|
43
|
-
|
44
|
-
|
45
|
-
|
43
|
+
io-console (0.5.6)
|
44
|
+
irb (1.2.7)
|
45
|
+
reline (>= 0.1.5)
|
46
|
+
listen (3.2.1)
|
46
47
|
rb-fsevent (~> 0.10, >= 0.10.3)
|
47
48
|
rb-inotify (~> 0.9, >= 0.9.10)
|
48
|
-
lumberjack (1.
|
49
|
-
method_source (0.
|
50
|
-
minitest (5.
|
51
|
-
mysql2 (0.5.
|
49
|
+
lumberjack (1.2.8)
|
50
|
+
method_source (1.0.0)
|
51
|
+
minitest (5.14.2)
|
52
|
+
mysql2 (0.5.3)
|
52
53
|
nenv (0.3.0)
|
53
54
|
notiffany (0.1.3)
|
54
55
|
nenv (~> 0.1)
|
55
56
|
shellany (~> 0.0)
|
56
|
-
parallel (1.
|
57
|
-
parser (2.
|
58
|
-
ast (~> 2.4.
|
59
|
-
pry (0.
|
60
|
-
coderay (~> 1.1
|
61
|
-
method_source (~>
|
57
|
+
parallel (1.19.2)
|
58
|
+
parser (2.7.2.0)
|
59
|
+
ast (~> 2.4.1)
|
60
|
+
pry (0.13.1)
|
61
|
+
coderay (~> 1.1)
|
62
|
+
method_source (~> 1.0)
|
62
63
|
rainbow (3.0.0)
|
63
|
-
rake (13.0.
|
64
|
-
rb-fsevent (0.10.
|
65
|
-
rb-inotify (0.10.
|
64
|
+
rake (13.0.1)
|
65
|
+
rb-fsevent (0.10.4)
|
66
|
+
rb-inotify (0.10.1)
|
66
67
|
ffi (~> 1.0)
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
rspec
|
72
|
-
rspec-
|
73
|
-
|
68
|
+
regexp_parser (1.8.2)
|
69
|
+
reline (0.1.7)
|
70
|
+
io-console (~> 0.5)
|
71
|
+
rexml (3.2.4)
|
72
|
+
rspec (3.10.0)
|
73
|
+
rspec-core (~> 3.10.0)
|
74
|
+
rspec-expectations (~> 3.10.0)
|
75
|
+
rspec-mocks (~> 3.10.0)
|
76
|
+
rspec-core (3.10.0)
|
77
|
+
rspec-support (~> 3.10.0)
|
78
|
+
rspec-expectations (3.10.0)
|
74
79
|
diff-lcs (>= 1.2.0, < 2.0)
|
75
|
-
rspec-support (~> 3.
|
76
|
-
rspec-mocks (3.
|
80
|
+
rspec-support (~> 3.10.0)
|
81
|
+
rspec-mocks (3.10.0)
|
77
82
|
diff-lcs (>= 1.2.0, < 2.0)
|
78
|
-
rspec-support (~> 3.
|
79
|
-
rspec-support (3.
|
80
|
-
rubocop (0.
|
81
|
-
jaro_winkler (~> 1.5.1)
|
83
|
+
rspec-support (~> 3.10.0)
|
84
|
+
rspec-support (3.10.0)
|
85
|
+
rubocop (0.93.1)
|
82
86
|
parallel (~> 1.10)
|
83
|
-
parser (>= 2.
|
87
|
+
parser (>= 2.7.1.5)
|
84
88
|
rainbow (>= 2.2.2, < 4.0)
|
89
|
+
regexp_parser (>= 1.8)
|
90
|
+
rexml
|
91
|
+
rubocop-ast (>= 0.6.0)
|
85
92
|
ruby-progressbar (~> 1.7)
|
86
|
-
unicode-display_width (>= 1.4.0, <
|
87
|
-
rubocop-
|
88
|
-
|
89
|
-
rubocop-
|
90
|
-
rubocop (>= 0.
|
93
|
+
unicode-display_width (>= 1.4.0, < 2.0)
|
94
|
+
rubocop-ast (1.1.0)
|
95
|
+
parser (>= 2.7.1.5)
|
96
|
+
rubocop-performance (1.8.1)
|
97
|
+
rubocop (>= 0.87.0)
|
98
|
+
rubocop-ast (>= 0.4.0)
|
99
|
+
rubocop-rspec (1.44.1)
|
100
|
+
rubocop (~> 0.87)
|
101
|
+
rubocop-ast (>= 0.7.1)
|
91
102
|
ruby-progressbar (1.10.1)
|
92
103
|
shellany (0.0.1)
|
93
|
-
thor (0.
|
104
|
+
thor (1.0.1)
|
94
105
|
thread_safe (0.3.6)
|
95
|
-
tty-cursor (0.7.
|
96
|
-
tty-spinner (0.9.
|
106
|
+
tty-cursor (0.7.1)
|
107
|
+
tty-spinner (0.9.3)
|
97
108
|
tty-cursor (~> 0.7)
|
98
|
-
tzinfo (1.2.
|
109
|
+
tzinfo (1.2.7)
|
99
110
|
thread_safe (~> 0.1)
|
100
|
-
unicode-display_width (1.
|
101
|
-
zeitwerk (2.
|
111
|
+
unicode-display_width (1.7.0)
|
112
|
+
zeitwerk (2.4.1)
|
102
113
|
|
103
114
|
PLATFORMS
|
104
115
|
ruby
|
@@ -120,4 +131,4 @@ DEPENDENCIES
|
|
120
131
|
ziptz!
|
121
132
|
|
122
133
|
BUNDLED WITH
|
123
|
-
2.
|
134
|
+
2.1.4
|
data/LICENSE
CHANGED
data/README.md
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
# Ziptz
|
2
2
|
[![Version](http://img.shields.io/gem/v/ziptz.svg?style=flat)](https://rubygems.org/gems/ziptz)
|
3
|
-
[![Build Status](http://img.shields.io/travis/infused/ziptz/master.svg?style=flat)](http://travis-ci.
|
3
|
+
[![Build Status](http://img.shields.io/travis/infused/ziptz/master.svg?style=flat)](http://travis-ci.com/infused/ziptz)
|
4
4
|
[![Total Downloads](https://img.shields.io/gem/dt/ziptz.svg)](https://rubygems.org/gems/ziptz/)
|
5
5
|
[![License](https://img.shields.io/github/license/infused/ziptz.svg)](https://github.com/infused/ziptz)
|
6
6
|
|
7
7
|
Get time zone and daylight saving time 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>February 2021</b>.</i>
|
10
10
|
|
11
11
|
## Installation
|
12
12
|
|
@@ -24,7 +24,7 @@ Get the time zone name for any ZIP code:
|
|
24
24
|
|
25
25
|
Get the time zone offset for any ZIP code:
|
26
26
|
|
27
|
-
z.time_zone_offset('97213') #=> -
|
27
|
+
z.time_zone_offset('97213') #=> -28800
|
28
28
|
|
29
29
|
<em>Note that offsets do not include daylight saving time.</em>
|
30
30
|
|
@@ -39,23 +39,101 @@ Get all the zip codes in a time zone:
|
|
39
39
|
|
40
40
|
## Supported Time Zones
|
41
41
|
|
42
|
-
*
|
43
|
-
*
|
44
|
-
*
|
45
|
-
*
|
46
|
-
*
|
47
|
-
*
|
48
|
-
*
|
49
|
-
*
|
50
|
-
*
|
51
|
-
*
|
52
|
-
*
|
53
|
-
*
|
54
|
-
*
|
55
|
-
*
|
42
|
+
* America/Adak
|
43
|
+
* America/Anchorage
|
44
|
+
* America/Boise
|
45
|
+
* America/Chicago
|
46
|
+
* America/Denver
|
47
|
+
* America/Detroit
|
48
|
+
* America/Indiana/Indianapolis
|
49
|
+
* America/Indiana/Knox
|
50
|
+
* America/Indiana/Marengo
|
51
|
+
* America/Indiana/Petersburg
|
52
|
+
* America/Indiana/Tell_City
|
53
|
+
* America/Indiana/Vevay
|
54
|
+
* America/Indiana/Vincennes
|
55
|
+
* America/Indiana/Winamac
|
56
|
+
* America/Juneau
|
57
|
+
* America/Kentucky/Louisville
|
58
|
+
* America/Kentucky/Monticello
|
59
|
+
* America/Los_Angeles
|
60
|
+
* America/Menominee
|
61
|
+
* America/Metlakatla
|
62
|
+
* America/New_York
|
63
|
+
* America/Nome
|
64
|
+
* America/North_Dakota/Beulah
|
65
|
+
* America/North_Dakota/Center
|
66
|
+
* America/North_Dakota/New_Salem
|
67
|
+
* America/Phoenix
|
68
|
+
* America/Puerto_Rico
|
69
|
+
* America/Sitka
|
70
|
+
* America/St_Thomas
|
71
|
+
* America/Yakutat
|
72
|
+
* Pacific/Chuuk
|
73
|
+
* Pacific/Guam
|
74
|
+
* Pacific/Honolulu
|
75
|
+
* Pacific/Kosrae
|
76
|
+
* Pacific/Kwajalein
|
77
|
+
* Pacific/Majuro
|
78
|
+
* Pacific/Pago_Pago
|
79
|
+
* Pacific/Palau
|
80
|
+
* Pacific/Pohnpei
|
81
|
+
* Pacific/Saipan
|
82
|
+
* Pacific/Wake
|
56
83
|
|
57
84
|
<em>Note that APO/FPO zip codes will not return a known time zone offset.</em>
|
58
85
|
|
86
|
+
## Prefer raw data?
|
87
|
+
|
88
|
+
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.
|
89
|
+
|
90
|
+
## Version 3 breaking changes
|
91
|
+
|
92
|
+
* APO, DPO, and FPO zip codes are no longer included, because they are non-geographic.
|
93
|
+
* Time zone offset are now specified in seconds instead of hours.
|
94
|
+
* Time zone are now more granular. The full list of time zones is:
|
95
|
+
* America/Adak
|
96
|
+
* America/Anchorage
|
97
|
+
* America/Boise
|
98
|
+
* America/Chicago
|
99
|
+
* America/Denver
|
100
|
+
* America/Detroit
|
101
|
+
* America/Indiana/Indianapolis
|
102
|
+
* America/Indiana/Knox
|
103
|
+
* America/Indiana/Marengo
|
104
|
+
* America/Indiana/Petersburg
|
105
|
+
* America/Indiana/Tell_City
|
106
|
+
* America/Indiana/Vevay
|
107
|
+
* America/Indiana/Vincennes
|
108
|
+
* America/Indiana/Winamac
|
109
|
+
* America/Juneau
|
110
|
+
* America/Kentucky/Louisville
|
111
|
+
* America/Kentucky/Monticello
|
112
|
+
* America/Los_Angeles
|
113
|
+
* America/Menominee
|
114
|
+
* America/Metlakatla
|
115
|
+
* America/New_York
|
116
|
+
* America/Nome
|
117
|
+
* America/North_Dakota/Beulah
|
118
|
+
* America/North_Dakota/Center
|
119
|
+
* America/North_Dakota/New_Salem
|
120
|
+
* America/Phoenix
|
121
|
+
* America/Puerto_Rico
|
122
|
+
* America/Sitka
|
123
|
+
* America/St_Thomas
|
124
|
+
* America/Yakutat
|
125
|
+
* Pacific/Chuuk
|
126
|
+
* Pacific/Guam
|
127
|
+
* Pacific/Honolulu
|
128
|
+
* Pacific/Kosrae
|
129
|
+
* Pacific/Kwajalein
|
130
|
+
* Pacific/Majuro
|
131
|
+
* Pacific/Pago_Pago
|
132
|
+
* Pacific/Palau
|
133
|
+
* Pacific/Pohnpei
|
134
|
+
* Pacific/Saipan
|
135
|
+
* Pacific/Wake
|
136
|
+
|
59
137
|
## Version 2 breaking changes
|
60
138
|
|
61
139
|
Time zone names now reflect standard tz-database names.
|
@@ -76,7 +154,7 @@ Time zone names now reflect standard tz-database names.
|
|
76
154
|
|
77
155
|
## License
|
78
156
|
|
79
|
-
Copyright (c) 2015-
|
157
|
+
Copyright (c) 2015-2021 Keith Morrison <<keithm@infused.org>>
|
80
158
|
|
81
159
|
Permission is hereby granted, free of charge, to any person
|
82
160
|
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.0'.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
|