timezone 0.1.5 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +4 -0
- data/CHANGES.markdown +22 -0
- data/CONTRIBUTING.markdown +7 -0
- data/README.markdown +5 -1
- data/Rakefile +10 -0
- data/data/Africa/Cairo.json +0 -720
- data/data/Africa/Casablanca.json +18 -0
- data/data/Africa/Dar_es_Salaam.json +5 -5
- data/data/Africa/Juba.json +318 -0
- data/data/Africa/Kampala.json +5 -5
- data/data/Africa/Nairobi.json +5 -5
- data/data/America/Coral_Harbour.json +75 -0
- data/data/America/Creston.json +39 -0
- data/data/America/Goose_Bay.json +325 -316
- data/data/America/Havana.json +4 -4
- data/data/America/Juneau.json +6 -6
- data/data/America/Kralendijk.json +30 -0
- data/data/America/Lower_Princes.json +30 -0
- data/data/America/Metlakatla.json +345 -0
- data/data/America/North_Dakota/Beulah.json +1596 -0
- data/data/America/Resolute.json +313 -322
- data/data/America/Santiago.json +8 -8
- data/data/America/Sitka.json +1560 -0
- data/data/America/St_Johns.json +325 -316
- data/data/Asia/Anadyr.json +2 -713
- data/data/Asia/Hebron.json +876 -0
- data/data/Asia/Irkutsk.json +2 -713
- data/data/Asia/Istanbul.json +4 -4
- data/data/Asia/Kamchatka.json +2 -713
- data/data/Asia/Krasnoyarsk.json +2 -713
- data/data/Asia/Magadan.json +2 -713
- data/data/Asia/Novokuznetsk.json +2 -713
- data/data/Asia/Novosibirsk.json +2 -713
- data/data/Asia/Omsk.json +2 -713
- data/data/Asia/Sakhalin.json +2 -713
- data/data/Asia/Vladivostok.json +2 -713
- data/data/Asia/Yakutsk.json +2 -713
- data/data/Asia/Yekaterinburg.json +2 -713
- data/data/Atlantic/Stanley.json +0 -18
- data/data/Europe/Istanbul.json +4 -4
- data/data/Europe/Kaliningrad.json +2 -713
- data/data/Europe/Moscow.json +2 -713
- data/data/Europe/Samara.json +2 -713
- data/data/Europe/Volgograd.json +2 -713
- data/data/Pacific/Apia.json +32 -5
- data/data/Pacific/Chuuk.json +0 -0
- data/data/Pacific/Easter.json +8 -8
- data/data/Pacific/Fiji.json +4 -4
- data/data/Pacific/Honolulu.json +10 -19
- data/data/Pacific/Pohnpei.json +0 -0
- data/lib/timezone/rule.rb +30 -0
- data/lib/timezone/version.rb +1 -1
- data/lib/timezone/zone.rb +18 -1
- data/test/data/Helsinki_rules_without_timestamps.json +1017 -0
- data/test/rule_test.rb +42 -0
- data/test/timezone_test.rb +13 -10
- data/timezone.gemspec +3 -0
- metadata +54 -6
- data/data/LICENSE +0 -21
data/test/rule_test.rb
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'timezone/rule'
|
2
|
+
require 'minitest/autorun'
|
3
|
+
|
4
|
+
describe Timezone::Rule do
|
5
|
+
before do
|
6
|
+
Timezone.rules.clear
|
7
|
+
@rule = Timezone::Rule.new('Zion')
|
8
|
+
end
|
9
|
+
|
10
|
+
it 'adds itself to the rules' do
|
11
|
+
assert_equal ['Zion'], Timezone.rules.keys
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'adds multiple rules with the same name' do
|
15
|
+
Timezone::Rule.new('Zion')
|
16
|
+
assert_equal 2, Timezone.rules['Zion'].count
|
17
|
+
end
|
18
|
+
|
19
|
+
describe '#offset' do
|
20
|
+
it 'properly calculates hours' do
|
21
|
+
@rule.save = '1:00'
|
22
|
+
assert_equal 3_600, @rule.offset
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'properly calculates minutes' do
|
26
|
+
@rule.save = '2:20'
|
27
|
+
assert_equal 8_400, @rule.offset
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe '#dst?' do
|
32
|
+
it 'knows standard time' do
|
33
|
+
@rule.letter = 'S'
|
34
|
+
assert !@rule.dst?
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'knows daylight savings time' do
|
38
|
+
@rule.letter = 'D'
|
39
|
+
assert @rule.dst?
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
data/test/timezone_test.rb
CHANGED
@@ -1,9 +1,8 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require 'timezone'
|
2
|
+
require 'timezone/zone'
|
3
3
|
require 'test/unit'
|
4
4
|
|
5
5
|
class TimezoneTest < Test::Unit::TestCase
|
6
|
-
|
7
6
|
def test_valid_timezone
|
8
7
|
assert_nothing_raised do
|
9
8
|
Timezone::Zone.new :zone => 'Australia/Sydney'
|
@@ -95,13 +94,6 @@ class TimezoneTest < Test::Unit::TestCase
|
|
95
94
|
assert_equal 'Australia/Adelaide', timezone.zone
|
96
95
|
end
|
97
96
|
|
98
|
-
def test_using_old_ws_geonames_api
|
99
|
-
Timezone::Configure.begin { |c| c.url = 'ws.geonames.org' }
|
100
|
-
timezone = Timezone::Zone.new :latlon => [-34.92771808058, 138.477041423321]
|
101
|
-
assert_equal 'Australia/Adelaide', timezone.zone
|
102
|
-
Timezone::Configure.begin { |c| c.url = nil }
|
103
|
-
end
|
104
|
-
|
105
97
|
def test_australian_timezone_with_dst
|
106
98
|
timezone = Timezone::Zone.new :zone => 'Australia/Adelaide'
|
107
99
|
utc = Time.utc(2010, 12, 23, 19, 37, 15)
|
@@ -140,4 +132,15 @@ class TimezoneTest < Test::Unit::TestCase
|
|
140
132
|
assert_equal timezone.utc_offset(utc), 10800
|
141
133
|
end
|
142
134
|
|
135
|
+
def test_utc_offset_without_timestamps
|
136
|
+
File.open(File.join(File.dirname(__FILE__),"data/Helsinki_rules_without_timestamps.json")) do |f|
|
137
|
+
rules = JSON.parse(f.read)
|
138
|
+
timezone = Timezone::Zone.new :zone => 'Europe/Helsinki'
|
139
|
+
timezone.rules = rules
|
140
|
+
utc = Time.utc(2012, 3, 25, 0, 59, 59)
|
141
|
+
assert_equal timezone.utc_offset(utc), 7200
|
142
|
+
utc = Time.utc(2012, 3, 25, 1, 0, 0)
|
143
|
+
assert_equal timezone.utc_offset(utc), 10800
|
144
|
+
end
|
145
|
+
end
|
143
146
|
end
|
data/timezone.gemspec
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: timezone
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1
|
4
|
+
version: 0.2.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,8 +9,40 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
13
|
-
dependencies:
|
12
|
+
date: 2013-01-14 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rake
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: minitest
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
14
46
|
description: A simple way to get accurate current and historical timezone information
|
15
47
|
based on zone or latitude and longitude coordinates. This gem uses the tz database
|
16
48
|
(http://www.twinsun.com/tz/tz-link.htm) for historical timezone information. It
|
@@ -24,6 +56,9 @@ extra_rdoc_files:
|
|
24
56
|
- License.txt
|
25
57
|
files:
|
26
58
|
- .gitignore
|
59
|
+
- .travis.yml
|
60
|
+
- CHANGES.markdown
|
61
|
+
- CONTRIBUTING.markdown
|
27
62
|
- Gemfile
|
28
63
|
- License.txt
|
29
64
|
- README.markdown
|
@@ -53,6 +88,7 @@ files:
|
|
53
88
|
- data/Africa/Gaborone.json
|
54
89
|
- data/Africa/Harare.json
|
55
90
|
- data/Africa/Johannesburg.json
|
91
|
+
- data/Africa/Juba.json
|
56
92
|
- data/Africa/Kampala.json
|
57
93
|
- data/Africa/Khartoum.json
|
58
94
|
- data/Africa/Kigali.json
|
@@ -116,7 +152,9 @@ files:
|
|
116
152
|
- data/America/Cayman.json
|
117
153
|
- data/America/Chicago.json
|
118
154
|
- data/America/Chihuahua.json
|
155
|
+
- data/America/Coral_Harbour.json
|
119
156
|
- data/America/Costa_Rica.json
|
157
|
+
- data/America/Creston.json
|
120
158
|
- data/America/Cuiaba.json
|
121
159
|
- data/America/Curacao.json
|
122
160
|
- data/America/Danmarkshavn.json
|
@@ -155,9 +193,11 @@ files:
|
|
155
193
|
- data/America/Juneau.json
|
156
194
|
- data/America/Kentucky/Louisville.json
|
157
195
|
- data/America/Kentucky/Monticello.json
|
196
|
+
- data/America/Kralendijk.json
|
158
197
|
- data/America/La_Paz.json
|
159
198
|
- data/America/Lima.json
|
160
199
|
- data/America/Los_Angeles.json
|
200
|
+
- data/America/Lower_Princes.json
|
161
201
|
- data/America/Maceio.json
|
162
202
|
- data/America/Managua.json
|
163
203
|
- data/America/Manaus.json
|
@@ -167,6 +207,7 @@ files:
|
|
167
207
|
- data/America/Mazatlan.json
|
168
208
|
- data/America/Menominee.json
|
169
209
|
- data/America/Merida.json
|
210
|
+
- data/America/Metlakatla.json
|
170
211
|
- data/America/Mexico_City.json
|
171
212
|
- data/America/Miquelon.json
|
172
213
|
- data/America/Moncton.json
|
@@ -179,6 +220,7 @@ files:
|
|
179
220
|
- data/America/Nipigon.json
|
180
221
|
- data/America/Nome.json
|
181
222
|
- data/America/Noronha.json
|
223
|
+
- data/America/North_Dakota/Beulah.json
|
182
224
|
- data/America/North_Dakota/Center.json
|
183
225
|
- data/America/North_Dakota/New_Salem.json
|
184
226
|
- data/America/Ojinaga.json
|
@@ -203,6 +245,7 @@ files:
|
|
203
245
|
- data/America/Sao_Paulo.json
|
204
246
|
- data/America/Scoresbysund.json
|
205
247
|
- data/America/Shiprock.json
|
248
|
+
- data/America/Sitka.json
|
206
249
|
- data/America/St_Barthelemy.json
|
207
250
|
- data/America/St_Johns.json
|
208
251
|
- data/America/St_Kitts.json
|
@@ -257,6 +300,7 @@ files:
|
|
257
300
|
- data/Asia/Dushanbe.json
|
258
301
|
- data/Asia/Gaza.json
|
259
302
|
- data/Asia/Harbin.json
|
303
|
+
- data/Asia/Hebron.json
|
260
304
|
- data/Asia/Ho_Chi_Minh.json
|
261
305
|
- data/Asia/Hong_Kong.json
|
262
306
|
- data/Asia/Hovd.json
|
@@ -441,7 +485,6 @@ files:
|
|
441
485
|
- data/Indian/Mauritius.json
|
442
486
|
- data/Indian/Mayotte.json
|
443
487
|
- data/Indian/Reunion.json
|
444
|
-
- data/LICENSE
|
445
488
|
- data/MET.json
|
446
489
|
- data/MST.json
|
447
490
|
- data/MST7MDT.json
|
@@ -490,8 +533,11 @@ files:
|
|
490
533
|
- lib/timezone.rb
|
491
534
|
- lib/timezone/configure.rb
|
492
535
|
- lib/timezone/error.rb
|
536
|
+
- lib/timezone/rule.rb
|
493
537
|
- lib/timezone/version.rb
|
494
538
|
- lib/timezone/zone.rb
|
539
|
+
- test/data/Helsinki_rules_without_timestamps.json
|
540
|
+
- test/rule_test.rb
|
495
541
|
- test/timezone_test.rb
|
496
542
|
- timezone.gemspec
|
497
543
|
homepage: http://github.com/panthomakos/timezone
|
@@ -515,10 +561,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
515
561
|
version: '0'
|
516
562
|
requirements: []
|
517
563
|
rubyforge_project: timezone
|
518
|
-
rubygems_version: 1.8.
|
564
|
+
rubygems_version: 1.8.23
|
519
565
|
signing_key:
|
520
566
|
specification_version: 3
|
521
|
-
summary: timezone-0.1
|
567
|
+
summary: timezone-0.2.1
|
522
568
|
test_files:
|
569
|
+
- test/data/Helsinki_rules_without_timestamps.json
|
570
|
+
- test/rule_test.rb
|
523
571
|
- test/timezone_test.rb
|
524
572
|
has_rdoc:
|
data/data/LICENSE
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
The MIT License
|
2
|
-
|
3
|
-
Copyright (c) 2010 World Time Engine Ltd <http://worldtimeengine.com>
|
4
|
-
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
7
|
-
in the Software without restriction, including without limitation the rights
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
10
|
-
furnished to do so, subject to the following conditions:
|
11
|
-
|
12
|
-
The above copyright notice and this permission notice shall be included in
|
13
|
-
all copies or substantial portions of the Software.
|
14
|
-
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
-
THE SOFTWARE.
|