tzinfo 1.2.11 → 2.0.0

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.
Files changed (151) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data/.yardopts +3 -0
  4. data/CHANGES.md +469 -431
  5. data/LICENSE +13 -13
  6. data/README.md +368 -114
  7. data/lib/tzinfo/country.rb +131 -129
  8. data/lib/tzinfo/country_timezone.rb +70 -112
  9. data/lib/tzinfo/data_source.rb +389 -144
  10. data/lib/tzinfo/data_sources/constant_offset_data_timezone_info.rb +56 -0
  11. data/lib/tzinfo/data_sources/country_info.rb +42 -0
  12. data/lib/tzinfo/data_sources/data_timezone_info.rb +91 -0
  13. data/lib/tzinfo/data_sources/linked_timezone_info.rb +33 -0
  14. data/lib/tzinfo/data_sources/ruby_data_source.rb +141 -0
  15. data/lib/tzinfo/data_sources/timezone_info.rb +47 -0
  16. data/lib/tzinfo/data_sources/transitions_data_timezone_info.rb +214 -0
  17. data/lib/tzinfo/data_sources/zoneinfo_data_source.rb +573 -0
  18. data/lib/tzinfo/data_sources/zoneinfo_reader.rb +284 -0
  19. data/lib/tzinfo/data_sources.rb +8 -0
  20. data/lib/tzinfo/data_timezone.rb +33 -47
  21. data/lib/tzinfo/datetime_with_offset.rb +153 -0
  22. data/lib/tzinfo/format1/country_definer.rb +17 -0
  23. data/lib/tzinfo/format1/country_index_definition.rb +64 -0
  24. data/lib/tzinfo/format1/timezone_definer.rb +64 -0
  25. data/lib/tzinfo/format1/timezone_definition.rb +39 -0
  26. data/lib/tzinfo/format1/timezone_index_definition.rb +77 -0
  27. data/lib/tzinfo/format1.rb +10 -0
  28. data/lib/tzinfo/format2/country_definer.rb +68 -0
  29. data/lib/tzinfo/format2/country_index_definer.rb +68 -0
  30. data/lib/tzinfo/format2/country_index_definition.rb +46 -0
  31. data/lib/tzinfo/format2/timezone_definer.rb +94 -0
  32. data/lib/tzinfo/format2/timezone_definition.rb +73 -0
  33. data/lib/tzinfo/format2/timezone_index_definer.rb +45 -0
  34. data/lib/tzinfo/format2/timezone_index_definition.rb +55 -0
  35. data/lib/tzinfo/format2.rb +10 -0
  36. data/lib/tzinfo/info_timezone.rb +26 -21
  37. data/lib/tzinfo/linked_timezone.rb +33 -52
  38. data/lib/tzinfo/offset_timezone_period.rb +42 -0
  39. data/lib/tzinfo/string_deduper.rb +118 -0
  40. data/lib/tzinfo/time_with_offset.rb +128 -0
  41. data/lib/tzinfo/timestamp.rb +548 -0
  42. data/lib/tzinfo/timestamp_with_offset.rb +85 -0
  43. data/lib/tzinfo/timezone.rb +979 -502
  44. data/lib/tzinfo/timezone_offset.rb +84 -74
  45. data/lib/tzinfo/timezone_period.rb +151 -217
  46. data/lib/tzinfo/timezone_proxy.rb +70 -79
  47. data/lib/tzinfo/timezone_transition.rb +77 -109
  48. data/lib/tzinfo/transitions_timezone_period.rb +63 -0
  49. data/lib/tzinfo/version.rb +7 -0
  50. data/lib/tzinfo/with_offset.rb +61 -0
  51. data/lib/tzinfo.rb +60 -40
  52. data.tar.gz.sig +0 -0
  53. metadata +51 -115
  54. metadata.gz.sig +2 -3
  55. data/Rakefile +0 -107
  56. data/lib/tzinfo/annual_rules.rb +0 -51
  57. data/lib/tzinfo/country_index_definition.rb +0 -31
  58. data/lib/tzinfo/country_info.rb +0 -42
  59. data/lib/tzinfo/data_timezone_info.rb +0 -55
  60. data/lib/tzinfo/linked_timezone_info.rb +0 -26
  61. data/lib/tzinfo/offset_rationals.rb +0 -77
  62. data/lib/tzinfo/posix_time_zone_parser.rb +0 -136
  63. data/lib/tzinfo/ruby_core_support.rb +0 -176
  64. data/lib/tzinfo/ruby_country_info.rb +0 -74
  65. data/lib/tzinfo/ruby_data_source.rb +0 -136
  66. data/lib/tzinfo/time_or_datetime.rb +0 -351
  67. data/lib/tzinfo/timezone_definition.rb +0 -36
  68. data/lib/tzinfo/timezone_index_definition.rb +0 -54
  69. data/lib/tzinfo/timezone_info.rb +0 -30
  70. data/lib/tzinfo/timezone_transition_definition.rb +0 -104
  71. data/lib/tzinfo/transition_data_timezone_info.rb +0 -274
  72. data/lib/tzinfo/transition_rule.rb +0 -325
  73. data/lib/tzinfo/zoneinfo_country_info.rb +0 -37
  74. data/lib/tzinfo/zoneinfo_data_source.rb +0 -504
  75. data/lib/tzinfo/zoneinfo_timezone_info.rb +0 -516
  76. data/test/assets/payload.rb +0 -1
  77. data/test/tc_annual_rules.rb +0 -95
  78. data/test/tc_country.rb +0 -240
  79. data/test/tc_country_index_definition.rb +0 -69
  80. data/test/tc_country_info.rb +0 -16
  81. data/test/tc_country_timezone.rb +0 -173
  82. data/test/tc_data_source.rb +0 -218
  83. data/test/tc_data_timezone.rb +0 -99
  84. data/test/tc_data_timezone_info.rb +0 -18
  85. data/test/tc_info_timezone.rb +0 -34
  86. data/test/tc_linked_timezone.rb +0 -155
  87. data/test/tc_linked_timezone_info.rb +0 -23
  88. data/test/tc_offset_rationals.rb +0 -23
  89. data/test/tc_posix_time_zone_parser.rb +0 -261
  90. data/test/tc_ruby_core_support.rb +0 -168
  91. data/test/tc_ruby_country_info.rb +0 -110
  92. data/test/tc_ruby_data_source.rb +0 -175
  93. data/test/tc_time_or_datetime.rb +0 -674
  94. data/test/tc_timezone.rb +0 -1361
  95. data/test/tc_timezone_definition.rb +0 -113
  96. data/test/tc_timezone_index_definition.rb +0 -73
  97. data/test/tc_timezone_info.rb +0 -11
  98. data/test/tc_timezone_london.rb +0 -143
  99. data/test/tc_timezone_melbourne.rb +0 -142
  100. data/test/tc_timezone_new_york.rb +0 -142
  101. data/test/tc_timezone_offset.rb +0 -126
  102. data/test/tc_timezone_period.rb +0 -555
  103. data/test/tc_timezone_proxy.rb +0 -136
  104. data/test/tc_timezone_transition.rb +0 -366
  105. data/test/tc_timezone_transition_definition.rb +0 -295
  106. data/test/tc_timezone_utc.rb +0 -27
  107. data/test/tc_transition_data_timezone_info.rb +0 -433
  108. data/test/tc_transition_rule.rb +0 -663
  109. data/test/tc_zoneinfo_country_info.rb +0 -78
  110. data/test/tc_zoneinfo_data_source.rb +0 -1226
  111. data/test/tc_zoneinfo_timezone_info.rb +0 -2149
  112. data/test/test_utils.rb +0 -214
  113. data/test/ts_all.rb +0 -7
  114. data/test/ts_all_ruby.rb +0 -5
  115. data/test/ts_all_zoneinfo.rb +0 -9
  116. data/test/tzinfo-data/tzinfo/data/definitions/America/Argentina/Buenos_Aires.rb +0 -89
  117. data/test/tzinfo-data/tzinfo/data/definitions/America/New_York.rb +0 -327
  118. data/test/tzinfo-data/tzinfo/data/definitions/Australia/Melbourne.rb +0 -230
  119. data/test/tzinfo-data/tzinfo/data/definitions/EST.rb +0 -19
  120. data/test/tzinfo-data/tzinfo/data/definitions/Etc/GMT__m__1.rb +0 -21
  121. data/test/tzinfo-data/tzinfo/data/definitions/Etc/GMT__p__1.rb +0 -21
  122. data/test/tzinfo-data/tzinfo/data/definitions/Etc/UTC.rb +0 -21
  123. data/test/tzinfo-data/tzinfo/data/definitions/Europe/Amsterdam.rb +0 -273
  124. data/test/tzinfo-data/tzinfo/data/definitions/Europe/Andorra.rb +0 -198
  125. data/test/tzinfo-data/tzinfo/data/definitions/Europe/London.rb +0 -333
  126. data/test/tzinfo-data/tzinfo/data/definitions/Europe/Paris.rb +0 -277
  127. data/test/tzinfo-data/tzinfo/data/definitions/Europe/Prague.rb +0 -235
  128. data/test/tzinfo-data/tzinfo/data/definitions/UTC.rb +0 -16
  129. data/test/tzinfo-data/tzinfo/data/indexes/countries.rb +0 -940
  130. data/test/tzinfo-data/tzinfo/data/indexes/timezones.rb +0 -609
  131. data/test/tzinfo-data/tzinfo/data/version.rb +0 -20
  132. data/test/tzinfo-data/tzinfo/data.rb +0 -8
  133. data/test/zoneinfo/America/Argentina/Buenos_Aires +0 -0
  134. data/test/zoneinfo/America/New_York +0 -0
  135. data/test/zoneinfo/Australia/Melbourne +0 -0
  136. data/test/zoneinfo/EST +0 -0
  137. data/test/zoneinfo/Etc/UTC +0 -0
  138. data/test/zoneinfo/Europe/Amsterdam +0 -0
  139. data/test/zoneinfo/Europe/Andorra +0 -0
  140. data/test/zoneinfo/Europe/London +0 -0
  141. data/test/zoneinfo/Europe/Paris +0 -0
  142. data/test/zoneinfo/Europe/Prague +0 -0
  143. data/test/zoneinfo/Factory +0 -0
  144. data/test/zoneinfo/iso3166.tab +0 -274
  145. data/test/zoneinfo/leapseconds +0 -78
  146. data/test/zoneinfo/posix/Europe/London +0 -0
  147. data/test/zoneinfo/posixrules +0 -0
  148. data/test/zoneinfo/right/Europe/London +0 -0
  149. data/test/zoneinfo/zone.tab +0 -452
  150. data/test/zoneinfo/zone1970.tab +0 -384
  151. data/tzinfo.gemspec +0 -21
data/test/tc_country.rb DELETED
@@ -1,240 +0,0 @@
1
- require File.join(File.expand_path(File.dirname(__FILE__)), 'test_utils')
2
-
3
- include TZInfo
4
-
5
- class TCCountry < Minitest::Test
6
- def setup
7
- @orig_data_source = DataSource.get
8
- Country.send :init_countries
9
- end
10
-
11
- def teardown
12
- DataSource.set(@orig_data_source)
13
- end
14
-
15
- def test_get_valid
16
- c = Country.get('GB')
17
-
18
- assert c
19
- assert_equal('GB', c.code)
20
- end
21
-
22
- def test_get_not_exist
23
- assert_raises(InvalidCountryCode) {
24
- Country.get('ZZ')
25
- }
26
- end
27
-
28
- def test_get_invalid
29
- assert_raises(InvalidCountryCode) {
30
- Country.get('../Countries/GB')
31
- }
32
- end
33
-
34
- def test_get_nil
35
- assert_raises(InvalidCountryCode) {
36
- Country.get(nil)
37
- }
38
- end
39
-
40
- def test_get_case
41
- assert_raises(InvalidCountryCode) {
42
- Country.get('gb')
43
- }
44
- end
45
-
46
- def test_get_tainted_loaded
47
- skip_if_taint_is_undefined_or_no_op
48
- Country.get('GB')
49
-
50
- safe_test(:unavailable => :skip) do
51
- code = 'GB'.dup.taint
52
- assert(code.tainted?)
53
- country = Country.get(code)
54
- assert_equal('GB', country.code)
55
- assert(code.tainted?)
56
- end
57
- end
58
-
59
- def test_get_tainted_and_frozen_loaded
60
- skip_if_taint_is_undefined_or_no_op
61
- Country.get('GB')
62
-
63
- safe_test do
64
- country = Country.get('GB'.dup.taint.freeze)
65
- assert_equal('GB', country.code)
66
- end
67
- end
68
-
69
- def test_get_tainted_not_previously_loaded
70
- skip_if_taint_is_undefined_or_no_op
71
-
72
- safe_test(:unavailable => :skip) do
73
- code = 'GB'.dup.taint
74
- assert(code.tainted?)
75
- country = Country.get(code)
76
- assert_equal('GB', country.code)
77
- assert(code.tainted?)
78
- end
79
- end
80
-
81
- def test_get_tainted_and_frozen_not_previously_loaded
82
- skip_if_taint_is_undefined_or_no_op
83
-
84
- safe_test do
85
- country = Country.get('GB'.dup.taint.freeze)
86
- assert_equal('GB', country.code)
87
- end
88
- end
89
-
90
- def test_new_nil
91
- assert_raises(InvalidCountryCode) {
92
- Country.new(nil)
93
- }
94
- end
95
-
96
- def test_new_arg
97
- c = Country.new('GB')
98
- assert_same(Country.get('GB'), c)
99
- end
100
-
101
- def test_new_arg_not_exist
102
- assert_raises(InvalidCountryCode) {
103
- Country.new('ZZ')
104
- }
105
- end
106
-
107
- def test_all_codes
108
- all_codes = Country.all_codes
109
- assert_kind_of(Array, all_codes)
110
- end
111
-
112
- def test_all
113
- all = Country.all
114
- assert_equal(Country.all_codes, all.collect {|c| c.code})
115
- end
116
-
117
- def test_code
118
- assert_equal('US', Country.get('US').code)
119
- end
120
-
121
- def test_name
122
- assert_kind_of(String, Country.get('US').name)
123
- end
124
-
125
- def test_to_s
126
- assert_equal(Country.get('US').name, Country.get('US').to_s)
127
- assert_equal(Country.get('GB').name, Country.get('GB').to_s)
128
- end
129
-
130
- def test_zone_identifiers
131
- zone_names = Country.get('US').zone_names
132
- assert_kind_of(Array, zone_names)
133
- assert_equal(true, zone_names.frozen?)
134
- end
135
-
136
- def test_zone_names
137
- assert_equal(Country.get('US').zone_identifiers, Country.get('US').zone_names)
138
- end
139
-
140
- def test_zones
141
- zones = Country.get('US').zones
142
- assert_kind_of(Array, zones)
143
- assert_equal(Country.get('US').zone_identifiers, zones.collect {|z| z.identifier})
144
-
145
- zones.each {|z| assert_kind_of(TimezoneProxy, z)}
146
- end
147
-
148
- def test_zone_info
149
- zones = Country.get('US').zone_info
150
- assert_kind_of(Array, zones)
151
- assert_equal(true, zones.frozen?)
152
-
153
- assert_equal(Country.get('US').zone_identifiers, zones.collect {|z| z.identifier})
154
- assert_equal(Country.get('US').zone_identifiers, zones.collect {|z| z.timezone.identifier})
155
-
156
- zones.each {|z| assert_kind_of(CountryTimezone, z)}
157
- end
158
-
159
- def test_compare
160
- assert_equal(0, Country.get('GB') <=> Country.get('GB'))
161
- assert_equal(-1, Country.get('GB') <=> Country.get('US'))
162
- assert_equal(1, Country.get('US') <=> Country.get('GB'))
163
- assert_equal(-1, Country.get('FR') <=> Country.get('US'))
164
- assert_equal(1, Country.get('US') <=> Country.get('FR'))
165
- end
166
-
167
- def test_compare_non_comparable
168
- assert_nil(Country.get('GB') <=> Object.new)
169
- end
170
-
171
- def test_equality
172
- assert_equal(true, Country.get('GB') == Country.get('GB'))
173
- assert_equal(false, Country.get('GB') == Country.get('US'))
174
- assert(!(Country.get('GB') == Object.new))
175
- end
176
-
177
- def test_eql
178
- assert_equal(true, Country.get('GB').eql?(Country.get('GB')))
179
- assert_equal(false, Country.get('GB').eql?(Country.get('US')))
180
- assert(!Country.get('GB').eql?(Object.new))
181
- end
182
-
183
- def test_hash
184
- assert_equal('GB'.hash, Country.get('GB').hash)
185
- assert_equal('US'.hash, Country.get('US').hash)
186
- end
187
-
188
- def test_marshal
189
- c = Country.get('US')
190
-
191
- # Should get back the same instance because load calls Country.get.
192
- assert_same(c, Marshal.load(Marshal.dump(c)))
193
- end
194
-
195
- def test_reload
196
- # If country gets reloaded for some reason, it needs to force a reload of
197
- # the country index.
198
-
199
- assert_equal('US', Country.get('US').code)
200
-
201
- # Suppress redefined method warnings.
202
- without_warnings do
203
- load 'tzinfo/country.rb'
204
- end
205
-
206
- assert_equal('US', Country.get('US').code)
207
- end
208
-
209
- def test_get_missing_data_source
210
- DataSource.set(DataSource.new)
211
-
212
- assert_raises(InvalidDataSource) do
213
- Country.get('GB')
214
- end
215
- end
216
-
217
- def test_new_missing_data_source
218
- DataSource.set(DataSource.new)
219
-
220
- assert_raises(InvalidDataSource) do
221
- Country.new('GB')
222
- end
223
- end
224
-
225
- def test_all_codes_missing_data_source
226
- DataSource.set(DataSource.new)
227
-
228
- assert_raises(InvalidDataSource) do
229
- Country.all_codes
230
- end
231
- end
232
-
233
- def test_all_missing_data_source
234
- DataSource.set(DataSource.new)
235
-
236
- assert_raises(InvalidDataSource) do
237
- Country.all
238
- end
239
- end
240
- end
@@ -1,69 +0,0 @@
1
- require File.join(File.expand_path(File.dirname(__FILE__)), 'test_utils')
2
-
3
- include TZInfo
4
-
5
- class TCCountryIndexDefinition < Minitest::Test
6
-
7
- module CountriesTest1
8
- include CountryIndexDefinition
9
-
10
- country 'ZZ', 'Country One' do |c|
11
- c.timezone 'Test/Zone/1', 3, 2, 41,20
12
- end
13
-
14
- country 'AA', 'Aland' do |c|
15
- c.timezone 'Test/Zone/3', 71,30, 358, 15
16
- c.timezone 'Test/Zone/2', 41, 20, 211, 30
17
- end
18
-
19
- country 'TE', 'Three'
20
- end
21
-
22
- module CountriesTest2
23
- include CountryIndexDefinition
24
-
25
- country 'CO', 'First Country' do |c|
26
- end
27
- end
28
-
29
- def test_module_1
30
- hash = CountriesTest1.countries
31
- assert_equal(3, hash.length)
32
- assert_equal(true, hash.frozen?)
33
-
34
- zz = hash['ZZ']
35
- aa = hash['AA']
36
- te = hash['TE']
37
-
38
- assert_kind_of(RubyCountryInfo, zz)
39
- assert_equal('ZZ', zz.code)
40
- assert_equal('Country One', zz.name)
41
- assert_equal(1, zz.zones.length)
42
- assert_equal('Test/Zone/1', zz.zones[0].identifier)
43
-
44
- assert_kind_of(RubyCountryInfo, aa)
45
- assert_equal('AA', aa.code)
46
- assert_equal('Aland', aa.name)
47
- assert_equal(2, aa.zones.length)
48
- assert_equal('Test/Zone/3', aa.zones[0].identifier)
49
- assert_equal('Test/Zone/2', aa.zones[1].identifier)
50
-
51
- assert_kind_of(RubyCountryInfo, te)
52
- assert_equal('TE', te.code)
53
- assert_equal('Three', te.name)
54
- assert_equal(0, te.zones.length)
55
- end
56
-
57
- def test_module_2
58
- hash = CountriesTest2.countries
59
- assert_equal(1, hash.length)
60
- assert_equal(true, hash.frozen?)
61
-
62
- co = hash['CO']
63
-
64
- assert_kind_of(RubyCountryInfo, co)
65
- assert_equal('CO', co.code)
66
- assert_equal('First Country', co.name)
67
- assert_equal(0, co.zones.length)
68
- end
69
- end
@@ -1,16 +0,0 @@
1
- require File.join(File.expand_path(File.dirname(__FILE__)), 'test_utils')
2
-
3
- include TZInfo
4
-
5
- class TCCountryInfo < Minitest::Test
6
-
7
- def test_code
8
- ci = CountryInfo.new('ZZ', 'Zzz') {|c| }
9
- assert_equal('ZZ', ci.code)
10
- end
11
-
12
- def test_name
13
- ci = CountryInfo.new('ZZ', 'Zzz') {|c| }
14
- assert_equal('Zzz', ci.name)
15
- end
16
- end
@@ -1,173 +0,0 @@
1
- require File.join(File.expand_path(File.dirname(__FILE__)), 'test_utils')
2
-
3
- include TZInfo
4
-
5
- class TCCountryTimezone < Minitest::Test
6
- def test_identifier_new!
7
- ct = CountryTimezone.new!('Europe/London', 2059, 40, -5, 16)
8
- assert_equal('Europe/London', ct.identifier)
9
- end
10
-
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)
18
- assert_equal(Rational(2059, 40), ct.latitude)
19
- end
20
-
21
- def test_latitude_after_freeze_new!
22
- ct = CountryTimezone.new!('Europe/London', 2059, 40, -5, 16)
23
- ct.freeze
24
- assert_equal(Rational(2059, 40), ct.latitude)
25
- end
26
-
27
- def test_latitude_new
28
- ct = CountryTimezone.new('Europe/London', Rational(2059, 40), Rational(-5, 16))
29
- assert_equal(Rational(2059, 40), ct.latitude)
30
- end
31
-
32
- def test_longitude_new!
33
- ct = CountryTimezone.new!('Europe/London', 2059, 40, -5, 16)
34
- assert_equal(Rational(-5, 16), ct.longitude)
35
- end
36
-
37
- def test_longitude_after_freeze_new!
38
- ct = CountryTimezone.new!('Europe/London', 2059, 40, -5, 16)
39
- ct.freeze
40
- assert_equal(Rational(-5, 16), ct.longitude)
41
- end
42
-
43
- def test_longitude_new
44
- ct = CountryTimezone.new('Europe/London', Rational(2059, 40), Rational(-5, 16))
45
- assert_equal(Rational(-5, 16), ct.longitude)
46
- end
47
-
48
- def test_description_omit_new!
49
- ct = CountryTimezone.new!('Europe/London', 2059, 40, -5, 16)
50
- assert_nil(ct.description)
51
- end
52
-
53
- def test_description_omit_new
54
- ct = CountryTimezone.new('Europe/London', Rational(2059, 40), Rational(-5, 16))
55
- assert_nil(ct.description)
56
- end
57
-
58
- def test_description_nil_new!
59
- ct = CountryTimezone.new!('Europe/London', 2059, 40, -5, 16, nil)
60
- assert_nil(ct.description)
61
- end
62
-
63
- def test_description_nil_new
64
- ct = CountryTimezone.new('Europe/London', Rational(2059, 40), Rational(-5, 16), nil)
65
- assert_nil(ct.description)
66
- end
67
-
68
- def test_description_new!
69
- ct = CountryTimezone.new!('America/New_York', 48857, 1200, -266423, 3600, 'Eastern Time')
70
- assert_equal('Eastern Time', ct.description)
71
- end
72
-
73
- def test_description_new
74
- ct = CountryTimezone.new('America/New_York', Rational(48857, 1200), Rational(-266423, 3600), 'Eastern Time')
75
- assert_equal('Eastern Time', ct.description)
76
- end
77
-
78
- def test_timezone
79
- ct = CountryTimezone.new('Europe/London', Rational(2059, 40), Rational(-5, 16))
80
- assert_kind_of(TimezoneProxy, ct.timezone)
81
- assert_equal('Europe/London', ct.timezone.identifier)
82
- end
83
-
84
- def test_description_or_friendly_idenfier_no_description
85
- ct = CountryTimezone.new('Europe/London', Rational(2059, 40), Rational(-5, 16))
86
- assert_equal('London', ct.description_or_friendly_identifier)
87
- end
88
-
89
- def test_description_or_friendly_idenfier_description
90
- ct = CountryTimezone.new('America/New_York', Rational(48857, 1200), Rational(-266423, 3600), 'Eastern Time')
91
- assert_equal('Eastern Time', ct.description_or_friendly_identifier)
92
- end
93
-
94
- def test_equality_1
95
- ct1 = CountryTimezone.new!('Europe/London', 2059, 40, -5, 16)
96
- ct2 = CountryTimezone.new!('Europe/London', 2059, 40, -5, 16)
97
- ct3 = CountryTimezone.new('Europe/London', Rational(2059, 40), Rational(-5, 16))
98
- ct4 = CountryTimezone.new!('Europe/London', 2059, 40, -5, 16, 'Description')
99
- ct5 = CountryTimezone.new!('Europe/LondonB', 2059, 40, -5, 16)
100
- ct6 = CountryTimezone.new!('Europe/London', 2060, 40, -5, 16)
101
- ct7 = CountryTimezone.new!('Europe/London', 2059, 40, -6, 16)
102
-
103
- assert_equal(true, ct1 == ct1)
104
- assert_equal(true, ct1 == ct2)
105
- assert_equal(true, ct1 == ct3)
106
- assert_equal(false, ct1 == ct4)
107
- assert_equal(false, ct1 == ct5)
108
- assert_equal(false, ct1 == ct6)
109
- assert_equal(false, ct1 == ct7)
110
- end
111
-
112
- def test_equality_2
113
- ct1 = CountryTimezone.new!('America/New_York', 48857, 1200, -266423, 3600, 'Eastern Time')
114
- ct2 = CountryTimezone.new!('America/New_York', 48857, 1200, -266423, 3600, 'Eastern Time2')
115
-
116
- assert_equal(true, ct1 == ct1)
117
- assert_equal(false, ct1 == ct2)
118
- end
119
-
120
- def test_equality_non_country_timezone
121
- ct = CountryTimezone.new('Europe/London', Rational(2059, 40), Rational(-5, 16))
122
-
123
- assert_equal(false, ct == Object.new)
124
- end
125
-
126
- def test_eql_1
127
- ct1 = CountryTimezone.new!('Europe/London', 2059, 40, -5, 16)
128
- ct2 = CountryTimezone.new!('Europe/London', 2059, 40, -5, 16)
129
- ct3 = CountryTimezone.new('Europe/London', Rational(2059, 40), Rational(-5, 16))
130
- ct4 = CountryTimezone.new!('Europe/London', 2059, 40, -5, 16, 'Description')
131
- ct5 = CountryTimezone.new!('Europe/LondonB', 2059, 40, -5, 16)
132
- ct6 = CountryTimezone.new!('Europe/London', 2060, 40, -5, 16)
133
- ct7 = CountryTimezone.new!('Europe/London', 2059, 40, -6, 16)
134
-
135
- assert_equal(true, ct1.eql?(ct1))
136
- assert_equal(true, ct1.eql?(ct2))
137
- assert_equal(true, ct1.eql?(ct3))
138
- assert_equal(false, ct1.eql?(ct4))
139
- assert_equal(false, ct1.eql?(ct5))
140
- assert_equal(false, ct1.eql?(ct6))
141
- assert_equal(false, ct1.eql?(ct7))
142
- end
143
-
144
- def test_eql_2
145
- ct1 = CountryTimezone.new!('America/New_York', 48857, 1200, -266423, 3600, 'Eastern Time')
146
- ct2 = CountryTimezone.new!('America/New_York', 48857, 1200, -266423, 3600, 'Eastern Time2')
147
-
148
- assert_equal(true, ct1.eql?(ct1))
149
- assert_equal(false, ct1.eql?(ct2))
150
- end
151
-
152
- def test_eql_non_country_timezone
153
- ct = CountryTimezone.new('Europe/London', Rational(2059, 40), Rational(-5, 16))
154
-
155
- assert_equal(false, ct.eql?(Object.new))
156
- end
157
-
158
- def test_hash_new!
159
- ct1 = CountryTimezone.new!('Europe/London', 2059, 40, -5, 16)
160
- ct2 = CountryTimezone.new!('America/New_York', 48857, 1200, -266423, 3600, 'Eastern Time')
161
-
162
- assert_equal('Europe/London'.hash ^ 2059.hash ^ 40.hash ^ -5.hash ^ 16.hash ^ nil.hash, ct1.hash)
163
- assert_equal('America/New_York'.hash ^ 48857.hash ^ 1200.hash ^ -266423.hash ^ 3600.hash ^ 'Eastern Time'.hash, ct2.hash)
164
- end
165
-
166
- def test_hash_new
167
- ct1 = CountryTimezone.new('Europe/London', Rational(2059, 40), Rational(-5, 16))
168
- ct2 = CountryTimezone.new('America/New_York', Rational(48857, 1200), Rational(-266423, 3600), 'Eastern Time')
169
-
170
- assert_equal('Europe/London'.hash ^ 2059.hash ^ 40.hash ^ -5.hash ^ 16.hash ^ nil.hash, ct1.hash)
171
- assert_equal('America/New_York'.hash ^ 48857.hash ^ 1200.hash ^ -266423.hash ^ 3600.hash ^ 'Eastern Time'.hash, ct2.hash)
172
- end
173
- end