tzinfo 1.1.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of tzinfo might be problematic. Click here for more details.

Files changed (77) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +0 -0
  4. data/CHANGES.md +33 -0
  5. data/LICENSE +1 -1
  6. data/README.md +36 -31
  7. data/Rakefile +17 -23
  8. data/lib/tzinfo.rb +0 -22
  9. data/lib/tzinfo/country.rb +3 -22
  10. data/lib/tzinfo/country_index_definition.rb +0 -22
  11. data/lib/tzinfo/country_info.rb +0 -22
  12. data/lib/tzinfo/country_timezone.rb +46 -31
  13. data/lib/tzinfo/data_source.rb +7 -24
  14. data/lib/tzinfo/data_timezone.rb +7 -22
  15. data/lib/tzinfo/data_timezone_info.rb +0 -22
  16. data/lib/tzinfo/info_timezone.rb +0 -22
  17. data/lib/tzinfo/linked_timezone.rb +7 -22
  18. data/lib/tzinfo/linked_timezone_info.rb +0 -22
  19. data/lib/tzinfo/offset_rationals.rb +0 -22
  20. data/lib/tzinfo/ruby_core_support.rb +14 -22
  21. data/lib/tzinfo/ruby_country_info.rb +3 -25
  22. data/lib/tzinfo/ruby_data_source.rb +1 -23
  23. data/lib/tzinfo/time_or_datetime.rb +13 -27
  24. data/lib/tzinfo/timezone.rb +51 -23
  25. data/lib/tzinfo/timezone_definition.rb +0 -22
  26. data/lib/tzinfo/timezone_index_definition.rb +0 -22
  27. data/lib/tzinfo/timezone_info.rb +0 -22
  28. data/lib/tzinfo/timezone_offset.rb +0 -22
  29. data/lib/tzinfo/timezone_period.rb +1 -23
  30. data/lib/tzinfo/timezone_proxy.rb +6 -23
  31. data/lib/tzinfo/timezone_transition.rb +2 -24
  32. data/lib/tzinfo/timezone_transition_definition.rb +1 -23
  33. data/lib/tzinfo/transition_data_timezone_info.rb +0 -22
  34. data/lib/tzinfo/zoneinfo_country_info.rb +1 -23
  35. data/lib/tzinfo/zoneinfo_data_source.rb +177 -61
  36. data/lib/tzinfo/zoneinfo_timezone_info.rb +0 -22
  37. data/test/tc_country.rb +6 -24
  38. data/test/tc_country_index_definition.rb +1 -23
  39. data/test/tc_country_info.rb +1 -23
  40. data/test/tc_country_timezone.rb +82 -62
  41. data/test/tc_data_source.rb +22 -24
  42. data/test/tc_data_timezone.rb +12 -24
  43. data/test/tc_data_timezone_info.rb +1 -23
  44. data/test/tc_info_timezone.rb +1 -23
  45. data/test/tc_linked_timezone.rb +37 -24
  46. data/test/tc_linked_timezone_info.rb +1 -23
  47. data/test/tc_offset_rationals.rb +1 -23
  48. data/test/tc_ruby_core_support.rb +84 -33
  49. data/test/tc_ruby_country_info.rb +5 -27
  50. data/test/tc_ruby_data_source.rb +1 -23
  51. data/test/tc_time_or_datetime.rb +44 -36
  52. data/test/tc_timezone.rb +32 -48
  53. data/test/tc_timezone_definition.rb +1 -23
  54. data/test/tc_timezone_index_definition.rb +1 -23
  55. data/test/tc_timezone_info.rb +1 -23
  56. data/test/tc_timezone_london.rb +1 -23
  57. data/test/tc_timezone_melbourne.rb +1 -23
  58. data/test/tc_timezone_new_york.rb +1 -23
  59. data/test/tc_timezone_offset.rb +1 -23
  60. data/test/tc_timezone_period.rb +5 -27
  61. data/test/tc_timezone_proxy.rb +34 -28
  62. data/test/tc_timezone_transition.rb +1 -23
  63. data/test/tc_timezone_transition_definition.rb +1 -23
  64. data/test/tc_timezone_utc.rb +1 -23
  65. data/test/tc_transition_data_timezone_info.rb +3 -25
  66. data/test/tc_zoneinfo_country_info.rb +13 -35
  67. data/test/tc_zoneinfo_data_source.rb +358 -34
  68. data/test/tc_zoneinfo_timezone_info.rb +3 -27
  69. data/test/test_utils.rb +26 -30
  70. data/test/ts_all.rb +0 -22
  71. data/test/ts_all_ruby.rb +0 -22
  72. data/test/ts_all_zoneinfo.rb +0 -22
  73. data/test/tzinfo-data/tzinfo/data.rb +0 -22
  74. data/test/tzinfo-data/tzinfo/data/version.rb +0 -22
  75. data/tzinfo.gemspec +2 -2
  76. metadata +80 -80
  77. metadata.gz.sig +1 -3
@@ -1,25 +1,3 @@
1
- #--
2
- # Copyright (c) 2008-2013 Philip Ross
3
- #
4
- # Permission is hereby granted, free of charge, to any person obtaining a copy
5
- # of this software and associated documentation files (the "Software"), to deal
6
- # in the Software without restriction, including without limitation the rights
7
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
- # copies of the Software, and to permit persons to whom the Software is
9
- # furnished to do so, subject to the following conditions:
10
- #
11
- # The above copyright notice and this permission notice shall be included in all
12
- # copies or substantial portions of the Software.
13
- #
14
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20
- # THE SOFTWARE.
21
- #++
22
-
23
1
  module TZInfo
24
2
  # An InvalidZoneinfoFile exception is raised if an attempt is made to load an
25
3
  # invalid zoneinfo file.
@@ -1,30 +1,8 @@
1
- #--
2
- # Copyright (c) 2005-2013 Philip Ross
3
- #
4
- # Permission is hereby granted, free of charge, to any person obtaining a copy
5
- # of this software and associated documentation files (the "Software"), to deal
6
- # in the Software without restriction, including without limitation the rights
7
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
- # copies of the Software, and to permit persons to whom the Software is
9
- # furnished to do so, subject to the following conditions:
10
- #
11
- # The above copyright notice and this permission notice shall be included in all
12
- # copies or substantial portions of the Software.
13
- #
14
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20
- # THE SOFTWARE.
21
- #++
22
-
23
1
  require File.join(File.expand_path(File.dirname(__FILE__)), 'test_utils')
24
2
 
25
3
  include TZInfo
26
4
 
27
- class TCCountry < Test::Unit::TestCase
5
+ class TCCountry < Minitest::Test
28
6
  def setup
29
7
  @orig_data_source = DataSource.get
30
8
  Country.send :init_countries
@@ -105,7 +83,7 @@ class TCCountry < Test::Unit::TestCase
105
83
 
106
84
  def test_new_nil
107
85
  assert_raises(InvalidCountryCode) {
108
- c = Country.new(nil)
86
+ Country.new(nil)
109
87
  }
110
88
  end
111
89
 
@@ -180,6 +158,10 @@ class TCCountry < Test::Unit::TestCase
180
158
  assert_equal(1, Country.get('US') <=> Country.get('FR'))
181
159
  end
182
160
 
161
+ def test_compare_non_comparable
162
+ assert_nil(Country.get('GB') <=> Object.new)
163
+ end
164
+
183
165
  def test_equality
184
166
  assert_equal(true, Country.get('GB') == Country.get('GB'))
185
167
  assert_equal(false, Country.get('GB') == Country.get('US'))
@@ -1,30 +1,8 @@
1
- #--
2
- # Copyright (c) 2006-2013 Philip Ross
3
- #
4
- # Permission is hereby granted, free of charge, to any person obtaining a copy
5
- # of this software and associated documentation files (the "Software"), to deal
6
- # in the Software without restriction, including without limitation the rights
7
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
- # copies of the Software, and to permit persons to whom the Software is
9
- # furnished to do so, subject to the following conditions:
10
- #
11
- # The above copyright notice and this permission notice shall be included in all
12
- # copies or substantial portions of the Software.
13
- #
14
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20
- # THE SOFTWARE.
21
- #++
22
-
23
1
  require File.join(File.expand_path(File.dirname(__FILE__)), 'test_utils')
24
2
 
25
3
  include TZInfo
26
4
 
27
- class TCCountryIndexDefinition < Test::Unit::TestCase
5
+ class TCCountryIndexDefinition < Minitest::Test
28
6
 
29
7
  module CountriesTest1
30
8
  include CountryIndexDefinition
@@ -1,30 +1,8 @@
1
- #--
2
- # Copyright (c) 2006-2013 Philip Ross
3
- #
4
- # Permission is hereby granted, free of charge, to any person obtaining a copy
5
- # of this software and associated documentation files (the "Software"), to deal
6
- # in the Software without restriction, including without limitation the rights
7
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
- # copies of the Software, and to permit persons to whom the Software is
9
- # furnished to do so, subject to the following conditions:
10
- #
11
- # The above copyright notice and this permission notice shall be included in all
12
- # copies or substantial portions of the Software.
13
- #
14
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20
- # THE SOFTWARE.
21
- #++
22
-
23
1
  require File.join(File.expand_path(File.dirname(__FILE__)), 'test_utils')
24
2
 
25
3
  include TZInfo
26
4
 
27
- class TCCountryInfo < Test::Unit::TestCase
5
+ class TCCountryInfo < Minitest::Test
28
6
 
29
7
  def test_code
30
8
  ci = CountryInfo.new('ZZ', 'Zzz') {|c| }
@@ -1,139 +1,159 @@
1
- #--
2
- # Copyright (c) 2006-2013 Philip Ross
3
- #
4
- # Permission is hereby granted, free of charge, to any person obtaining a copy
5
- # of this software and associated documentation files (the "Software"), to deal
6
- # in the Software without restriction, including without limitation the rights
7
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
- # copies of the Software, and to permit persons to whom the Software is
9
- # furnished to do so, subject to the following conditions:
10
- #
11
- # The above copyright notice and this permission notice shall be included in all
12
- # copies or substantial portions of the Software.
13
- #
14
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20
- # THE SOFTWARE.
21
- #++
22
-
23
1
  require File.join(File.expand_path(File.dirname(__FILE__)), 'test_utils')
24
2
 
25
3
  include TZInfo
26
4
 
27
- class TCCountryTimezone < Test::Unit::TestCase
28
- def test_identifier
29
- ct = CountryTimezone.new('Europe/London', 2059, 40, -5, 16)
5
+ class TCCountryTimezone < Minitest::Test
6
+ def test_identifier_new!
7
+ ct = CountryTimezone.new!('Europe/London', 2059, 40, -5, 16)
30
8
  assert_equal('Europe/London', ct.identifier)
31
- end
9
+ end
32
10
 
33
- def test_latitude
34
- ct = CountryTimezone.new('Europe/London', 2059, 40, -5, 16)
11
+ def test_identifier_new
12
+ ct = CountryTimezone.new('Europe/London', Rational(2059, 40), Rational(-5, 16))
13
+ assert_equal('Europe/London', ct.identifier)
14
+ end
15
+
16
+ def test_latitude_new!
17
+ ct = CountryTimezone.new!('Europe/London', 2059, 40, -5, 16)
35
18
  assert_equal(Rational(2059, 40), ct.latitude)
36
19
  end
37
20
 
38
- def test_longitude
39
- ct = CountryTimezone.new('Europe/London', 2059, 40, -5, 16)
21
+ def test_latitude_new
22
+ ct = CountryTimezone.new('Europe/London', Rational(2059, 40), Rational(-5, 16))
23
+ assert_equal(Rational(2059, 40), ct.latitude)
24
+ end
25
+
26
+ def test_longitude_new!
27
+ ct = CountryTimezone.new!('Europe/London', 2059, 40, -5, 16)
28
+ assert_equal(Rational(-5, 16), ct.longitude)
29
+ end
30
+
31
+ def test_longitude_new
32
+ ct = CountryTimezone.new('Europe/London', Rational(2059, 40), Rational(-5, 16))
40
33
  assert_equal(Rational(-5, 16), ct.longitude)
41
34
  end
42
35
 
43
- def test_description_omit
44
- ct = CountryTimezone.new('Europe/London', 2059, 40, -5, 16)
36
+ def test_description_omit_new!
37
+ ct = CountryTimezone.new!('Europe/London', 2059, 40, -5, 16)
45
38
  assert_nil(ct.description)
46
39
  end
47
40
 
48
- def test_description_nil
49
- ct = CountryTimezone.new('Europe/London', 2059, 40, -5, 16, nil)
41
+ def test_description_omit_new
42
+ ct = CountryTimezone.new('Europe/London', Rational(2059, 40), Rational(-5, 16))
50
43
  assert_nil(ct.description)
51
44
  end
52
45
 
53
- def test_description
54
- ct = CountryTimezone.new('America/New_York', 48857, 1200, -266423, 3600, 'Eastern Time')
46
+ def test_description_nil_new!
47
+ ct = CountryTimezone.new!('Europe/London', 2059, 40, -5, 16, nil)
48
+ assert_nil(ct.description)
49
+ end
50
+
51
+ def test_description_nil_new
52
+ ct = CountryTimezone.new('Europe/London', Rational(2059, 40), Rational(-5, 16), nil)
53
+ assert_nil(ct.description)
54
+ end
55
+
56
+ def test_description_new!
57
+ ct = CountryTimezone.new!('America/New_York', 48857, 1200, -266423, 3600, 'Eastern Time')
58
+ assert_equal('Eastern Time', ct.description)
59
+ end
60
+
61
+ def test_description_new
62
+ ct = CountryTimezone.new('America/New_York', Rational(48857, 1200), Rational(-266423, 3600), 'Eastern Time')
55
63
  assert_equal('Eastern Time', ct.description)
56
64
  end
57
65
 
58
66
  def test_timezone
59
- ct = CountryTimezone.new('Europe/London', 2059, 40, -5, 16)
67
+ ct = CountryTimezone.new('Europe/London', Rational(2059, 40), Rational(-5, 16))
60
68
  assert_kind_of(TimezoneProxy, ct.timezone)
61
69
  assert_equal('Europe/London', ct.timezone.identifier)
62
70
  end
63
71
 
64
72
  def test_description_or_friendly_idenfier_no_description
65
- ct = CountryTimezone.new('Europe/London', 2059, 40, -5, 16)
73
+ ct = CountryTimezone.new('Europe/London', Rational(2059, 40), Rational(-5, 16))
66
74
  assert_equal('London', ct.description_or_friendly_identifier)
67
75
  end
68
76
 
69
77
  def test_description_or_friendly_idenfier_description
70
- ct = CountryTimezone.new('America/New_York', 48857, 1200, -266423, 3600, 'Eastern Time')
78
+ ct = CountryTimezone.new('America/New_York', Rational(48857, 1200), Rational(-266423, 3600), 'Eastern Time')
71
79
  assert_equal('Eastern Time', ct.description_or_friendly_identifier)
72
80
  end
73
81
 
74
82
  def test_equality_1
75
- ct1 = CountryTimezone.new('Europe/London', 2059, 40, -5, 16)
76
- ct2 = CountryTimezone.new('Europe/London', 2059, 40, -5, 16)
77
- ct3 = CountryTimezone.new('Europe/London', 2059, 40, -5, 16, 'Description')
78
- ct4 = CountryTimezone.new('Europe/LondonB', 2059, 40, -5, 16)
79
- ct5 = CountryTimezone.new('Europe/London', 2060, 40, -5, 16)
80
- ct6 = CountryTimezone.new('Europe/London', 2059, 40, -6, 16)
83
+ ct1 = CountryTimezone.new!('Europe/London', 2059, 40, -5, 16)
84
+ ct2 = CountryTimezone.new!('Europe/London', 2059, 40, -5, 16)
85
+ ct3 = CountryTimezone.new('Europe/London', Rational(2059, 40), Rational(-5, 16))
86
+ ct4 = CountryTimezone.new!('Europe/London', 2059, 40, -5, 16, 'Description')
87
+ ct5 = CountryTimezone.new!('Europe/LondonB', 2059, 40, -5, 16)
88
+ ct6 = CountryTimezone.new!('Europe/London', 2060, 40, -5, 16)
89
+ ct7 = CountryTimezone.new!('Europe/London', 2059, 40, -6, 16)
81
90
 
82
91
  assert_equal(true, ct1 == ct1)
83
92
  assert_equal(true, ct1 == ct2)
84
- assert_equal(false, ct1 == ct3)
93
+ assert_equal(true, ct1 == ct3)
85
94
  assert_equal(false, ct1 == ct4)
86
95
  assert_equal(false, ct1 == ct5)
87
96
  assert_equal(false, ct1 == ct6)
97
+ assert_equal(false, ct1 == ct7)
88
98
  end
89
99
 
90
100
  def test_equality_2
91
- ct1 = CountryTimezone.new('America/New_York', 48857, 1200, -266423, 3600, 'Eastern Time')
92
- ct2 = CountryTimezone.new('America/New_York', 48857, 1200, -266423, 3600, 'Eastern Time2')
101
+ ct1 = CountryTimezone.new!('America/New_York', 48857, 1200, -266423, 3600, 'Eastern Time')
102
+ ct2 = CountryTimezone.new!('America/New_York', 48857, 1200, -266423, 3600, 'Eastern Time2')
93
103
 
94
104
  assert_equal(true, ct1 == ct1)
95
105
  assert_equal(false, ct1 == ct2)
96
106
  end
97
107
 
98
108
  def test_equality_non_country_timezone
99
- ct = CountryTimezone.new('Europe/London', 2059, 40, -5, 16)
109
+ ct = CountryTimezone.new('Europe/London', Rational(2059, 40), Rational(-5, 16))
100
110
 
101
111
  assert_equal(false, ct == Object.new)
102
112
  end
103
113
 
104
114
  def test_eql_1
105
- ct1 = CountryTimezone.new('Europe/London', 2059, 40, -5, 16)
106
- ct2 = CountryTimezone.new('Europe/London', 2059, 40, -5, 16)
107
- ct3 = CountryTimezone.new('Europe/London', 2059, 40, -5, 16, 'Description')
108
- ct4 = CountryTimezone.new('Europe/LondonB', 2059, 40, -5, 16)
109
- ct5 = CountryTimezone.new('Europe/London', 2060, 40, -5, 16)
110
- ct6 = CountryTimezone.new('Europe/London', 2059, 40, -6, 16)
115
+ ct1 = CountryTimezone.new!('Europe/London', 2059, 40, -5, 16)
116
+ ct2 = CountryTimezone.new!('Europe/London', 2059, 40, -5, 16)
117
+ ct3 = CountryTimezone.new('Europe/London', Rational(2059, 40), Rational(-5, 16))
118
+ ct4 = CountryTimezone.new!('Europe/London', 2059, 40, -5, 16, 'Description')
119
+ ct5 = CountryTimezone.new!('Europe/LondonB', 2059, 40, -5, 16)
120
+ ct6 = CountryTimezone.new!('Europe/London', 2060, 40, -5, 16)
121
+ ct7 = CountryTimezone.new!('Europe/London', 2059, 40, -6, 16)
111
122
 
112
123
  assert_equal(true, ct1.eql?(ct1))
113
124
  assert_equal(true, ct1.eql?(ct2))
114
- assert_equal(false, ct1.eql?(ct3))
125
+ assert_equal(true, ct1.eql?(ct3))
115
126
  assert_equal(false, ct1.eql?(ct4))
116
127
  assert_equal(false, ct1.eql?(ct5))
117
128
  assert_equal(false, ct1.eql?(ct6))
129
+ assert_equal(false, ct1.eql?(ct7))
118
130
  end
119
131
 
120
132
  def test_eql_2
121
- ct1 = CountryTimezone.new('America/New_York', 48857, 1200, -266423, 3600, 'Eastern Time')
122
- ct2 = CountryTimezone.new('America/New_York', 48857, 1200, -266423, 3600, 'Eastern Time2')
133
+ ct1 = CountryTimezone.new!('America/New_York', 48857, 1200, -266423, 3600, 'Eastern Time')
134
+ ct2 = CountryTimezone.new!('America/New_York', 48857, 1200, -266423, 3600, 'Eastern Time2')
123
135
 
124
136
  assert_equal(true, ct1.eql?(ct1))
125
137
  assert_equal(false, ct1.eql?(ct2))
126
138
  end
127
139
 
128
140
  def test_eql_non_country_timezone
129
- ct = CountryTimezone.new('Europe/London', 2059, 40, -5, 16)
141
+ ct = CountryTimezone.new('Europe/London', Rational(2059, 40), Rational(-5, 16))
130
142
 
131
143
  assert_equal(false, ct.eql?(Object.new))
132
144
  end
133
145
 
134
- def test_hash
135
- ct1 = CountryTimezone.new('Europe/London', 2059, 40, -5, 16)
136
- ct2 = CountryTimezone.new('America/New_York', 48857, 1200, -266423, 3600, 'Eastern Time')
146
+ def test_hash_new!
147
+ ct1 = CountryTimezone.new!('Europe/London', 2059, 40, -5, 16)
148
+ ct2 = CountryTimezone.new!('America/New_York', 48857, 1200, -266423, 3600, 'Eastern Time')
149
+
150
+ assert_equal('Europe/London'.hash ^ 2059.hash ^ 40.hash ^ -5.hash ^ 16.hash ^ nil.hash, ct1.hash)
151
+ assert_equal('America/New_York'.hash ^ 48857.hash ^ 1200.hash ^ -266423.hash ^ 3600.hash ^ 'Eastern Time'.hash, ct2.hash)
152
+ end
153
+
154
+ def test_hash_new
155
+ ct1 = CountryTimezone.new('Europe/London', Rational(2059, 40), Rational(-5, 16))
156
+ ct2 = CountryTimezone.new('America/New_York', Rational(48857, 1200), Rational(-266423, 3600), 'Eastern Time')
137
157
 
138
158
  assert_equal('Europe/London'.hash ^ 2059.hash ^ 40.hash ^ -5.hash ^ 16.hash ^ nil.hash, ct1.hash)
139
159
  assert_equal('America/New_York'.hash ^ 48857.hash ^ 1200.hash ^ -266423.hash ^ 3600.hash ^ 'Eastern Time'.hash, ct2.hash)
@@ -1,31 +1,9 @@
1
- #--
2
- # Copyright (c) 2012-2013 Philip Ross
3
- #
4
- # Permission is hereby granted, free of charge, to any person obtaining a copy
5
- # of this software and associated documentation files (the "Software"), to deal
6
- # in the Software without restriction, including without limitation the rights
7
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
- # copies of the Software, and to permit persons to whom the Software is
9
- # furnished to do so, subject to the following conditions:
10
- #
11
- # The above copyright notice and this permission notice shall be included in all
12
- # copies or substantial portions of the Software.
13
- #
14
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20
- # THE SOFTWARE.
21
- #++
22
-
23
1
  require File.join(File.expand_path(File.dirname(__FILE__)), 'test_utils')
24
2
  require 'tmpdir'
25
3
 
26
4
  include TZInfo
27
5
 
28
- class TCDataSource < Test::Unit::TestCase
6
+ class TCDataSource < Minitest::Test
29
7
  class InitDataSource < DataSource
30
8
  end
31
9
 
@@ -162,6 +140,26 @@ class TCDataSource < Test::Unit::TestCase
162
140
  end
163
141
  end
164
142
 
143
+ def test_set_standard_zoneinfo_explicit_alternate_iso3166
144
+ Dir.mktmpdir('tzinfo_test_dir') do |dir|
145
+ zoneinfo_dir = File.join(dir, 'zoneinfo')
146
+ tab_dir = File.join(dir, 'tab')
147
+
148
+ FileUtils.mkdir(zoneinfo_dir)
149
+ FileUtils.mkdir(tab_dir)
150
+
151
+ FileUtils.touch(File.join(zoneinfo_dir, 'zone.tab'))
152
+
153
+ iso3166_file = File.join(tab_dir, 'iso3166.tab')
154
+ FileUtils.touch(iso3166_file)
155
+
156
+ DataSource.set(:zoneinfo, zoneinfo_dir, iso3166_file)
157
+ data_source = DataSource.get
158
+ assert_kind_of(ZoneinfoDataSource, data_source)
159
+ assert_equal(zoneinfo_dir, data_source.zoneinfo_dir)
160
+ end
161
+ end
162
+
165
163
  def test_set_standard_zoneinfo_search_not_found
166
164
  Dir.mktmpdir('tzinfo_test_dir') do |dir|
167
165
  ZoneinfoDataSource.search_path = [dir]
@@ -186,7 +184,7 @@ class TCDataSource < Test::Unit::TestCase
186
184
 
187
185
  def test_set_standard_zoneinfo_wrong_arg_count
188
186
  assert_raises(ArgumentError) do
189
- DataSource.set(:zoneinfo, 1, 2)
187
+ DataSource.set(:zoneinfo, 1, 2, 3)
190
188
  end
191
189
 
192
190
  assert_kind_of(InitDataSource, DataSource.get)
@@ -1,30 +1,8 @@
1
- #--
2
- # Copyright (c) 2005-2013 Philip Ross
3
- #
4
- # Permission is hereby granted, free of charge, to any person obtaining a copy
5
- # of this software and associated documentation files (the "Software"), to deal
6
- # in the Software without restriction, including without limitation the rights
7
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
- # copies of the Software, and to permit persons to whom the Software is
9
- # furnished to do so, subject to the following conditions:
10
- #
11
- # The above copyright notice and this permission notice shall be included in all
12
- # copies or substantial portions of the Software.
13
- #
14
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20
- # THE SOFTWARE.
21
- #++
22
-
23
1
  require File.join(File.expand_path(File.dirname(__FILE__)), 'test_utils')
24
2
 
25
3
  include TZInfo
26
4
 
27
- class TCDataTimezone < Test::Unit::TestCase
5
+ class TCDataTimezone < Minitest::Test
28
6
 
29
7
  class TestTimezoneInfo < TimezoneInfo
30
8
  attr_reader :utc
@@ -107,5 +85,15 @@ class TCDataTimezone < Test::Unit::TestCase
107
85
  assert_same(transitions, tz.transitions_up_to(utc_to, utc_from))
108
86
  assert_same(utc_to, tti.utc_to)
109
87
  assert_same(utc_from, tti.utc_from)
110
- end
88
+ end
89
+
90
+ def test_canonical_identifier
91
+ tz = DataTimezone.new(TestTimezoneInfo.new('Test/Zone', nil, [], []))
92
+ assert_equal('Test/Zone', tz.canonical_identifier)
93
+ end
94
+
95
+ def test_canonical_zone
96
+ tz = DataTimezone.new(TestTimezoneInfo.new('Test/Zone', nil, [], []))
97
+ assert_same(tz, tz.canonical_zone)
98
+ end
111
99
  end