tzinfo 1.2.6 → 2.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +1 -1
- data/.yardopts +3 -0
- data/CHANGES.md +494 -380
- data/LICENSE +13 -13
- data/README.md +368 -114
- data/lib/tzinfo.rb +59 -29
- data/lib/tzinfo/country.rb +141 -129
- data/lib/tzinfo/country_timezone.rb +70 -112
- data/lib/tzinfo/data_source.rb +389 -144
- data/lib/tzinfo/data_sources.rb +8 -0
- data/lib/tzinfo/data_sources/constant_offset_data_timezone_info.rb +56 -0
- data/lib/tzinfo/data_sources/country_info.rb +42 -0
- data/lib/tzinfo/data_sources/data_timezone_info.rb +91 -0
- data/lib/tzinfo/data_sources/linked_timezone_info.rb +33 -0
- data/lib/tzinfo/data_sources/ruby_data_source.rb +145 -0
- data/lib/tzinfo/data_sources/timezone_info.rb +47 -0
- data/lib/tzinfo/data_sources/transitions_data_timezone_info.rb +214 -0
- data/lib/tzinfo/data_sources/zoneinfo_data_source.rb +577 -0
- data/lib/tzinfo/data_sources/zoneinfo_reader.rb +288 -0
- data/lib/tzinfo/data_timezone.rb +33 -47
- data/lib/tzinfo/datetime_with_offset.rb +153 -0
- data/lib/tzinfo/format1.rb +10 -0
- data/lib/tzinfo/format1/country_definer.rb +17 -0
- data/lib/tzinfo/format1/country_index_definition.rb +64 -0
- data/lib/tzinfo/format1/timezone_definer.rb +64 -0
- data/lib/tzinfo/format1/timezone_definition.rb +39 -0
- data/lib/tzinfo/format1/timezone_index_definition.rb +77 -0
- data/lib/tzinfo/format2.rb +10 -0
- data/lib/tzinfo/format2/country_definer.rb +68 -0
- data/lib/tzinfo/format2/country_index_definer.rb +68 -0
- data/lib/tzinfo/format2/country_index_definition.rb +46 -0
- data/lib/tzinfo/format2/timezone_definer.rb +94 -0
- data/lib/tzinfo/format2/timezone_definition.rb +73 -0
- data/lib/tzinfo/format2/timezone_index_definer.rb +45 -0
- data/lib/tzinfo/format2/timezone_index_definition.rb +55 -0
- data/lib/tzinfo/info_timezone.rb +26 -21
- data/lib/tzinfo/linked_timezone.rb +33 -52
- data/lib/tzinfo/offset_timezone_period.rb +42 -0
- data/lib/tzinfo/string_deduper.rb +118 -0
- data/lib/tzinfo/time_with_offset.rb +128 -0
- data/lib/tzinfo/timestamp.rb +548 -0
- data/lib/tzinfo/timestamp_with_offset.rb +85 -0
- data/lib/tzinfo/timezone.rb +989 -502
- data/lib/tzinfo/timezone_offset.rb +84 -74
- data/lib/tzinfo/timezone_period.rb +151 -217
- data/lib/tzinfo/timezone_proxy.rb +70 -79
- data/lib/tzinfo/timezone_transition.rb +77 -109
- data/lib/tzinfo/transitions_timezone_period.rb +63 -0
- data/lib/tzinfo/untaint_ext.rb +18 -0
- data/lib/tzinfo/version.rb +7 -0
- data/lib/tzinfo/with_offset.rb +61 -0
- metadata +44 -100
- metadata.gz.sig +0 -0
- data/Rakefile +0 -107
- data/lib/tzinfo/country_index_definition.rb +0 -31
- data/lib/tzinfo/country_info.rb +0 -42
- data/lib/tzinfo/data_timezone_info.rb +0 -55
- data/lib/tzinfo/linked_timezone_info.rb +0 -26
- data/lib/tzinfo/offset_rationals.rb +0 -77
- data/lib/tzinfo/ruby_core_support.rb +0 -176
- data/lib/tzinfo/ruby_country_info.rb +0 -74
- data/lib/tzinfo/ruby_data_source.rb +0 -138
- data/lib/tzinfo/time_or_datetime.rb +0 -340
- data/lib/tzinfo/timezone_definition.rb +0 -36
- data/lib/tzinfo/timezone_index_definition.rb +0 -54
- data/lib/tzinfo/timezone_info.rb +0 -30
- data/lib/tzinfo/timezone_transition_definition.rb +0 -104
- data/lib/tzinfo/transition_data_timezone_info.rb +0 -274
- data/lib/tzinfo/zoneinfo_country_info.rb +0 -37
- data/lib/tzinfo/zoneinfo_data_source.rb +0 -496
- data/lib/tzinfo/zoneinfo_timezone_info.rb +0 -298
- data/test/tc_country.rb +0 -236
- data/test/tc_country_index_definition.rb +0 -69
- data/test/tc_country_info.rb +0 -16
- data/test/tc_country_timezone.rb +0 -173
- data/test/tc_data_source.rb +0 -218
- data/test/tc_data_timezone.rb +0 -99
- data/test/tc_data_timezone_info.rb +0 -18
- data/test/tc_info_timezone.rb +0 -34
- data/test/tc_linked_timezone.rb +0 -155
- data/test/tc_linked_timezone_info.rb +0 -23
- data/test/tc_offset_rationals.rb +0 -23
- data/test/tc_ruby_core_support.rb +0 -168
- data/test/tc_ruby_country_info.rb +0 -110
- data/test/tc_ruby_data_source.rb +0 -165
- data/test/tc_time_or_datetime.rb +0 -660
- data/test/tc_timezone.rb +0 -1359
- data/test/tc_timezone_definition.rb +0 -113
- data/test/tc_timezone_index_definition.rb +0 -73
- data/test/tc_timezone_info.rb +0 -11
- data/test/tc_timezone_london.rb +0 -143
- data/test/tc_timezone_melbourne.rb +0 -142
- data/test/tc_timezone_new_york.rb +0 -142
- data/test/tc_timezone_offset.rb +0 -126
- data/test/tc_timezone_period.rb +0 -555
- data/test/tc_timezone_proxy.rb +0 -136
- data/test/tc_timezone_transition.rb +0 -366
- data/test/tc_timezone_transition_definition.rb +0 -295
- data/test/tc_timezone_utc.rb +0 -27
- data/test/tc_transition_data_timezone_info.rb +0 -433
- data/test/tc_zoneinfo_country_info.rb +0 -78
- data/test/tc_zoneinfo_data_source.rb +0 -1204
- data/test/tc_zoneinfo_timezone_info.rb +0 -1234
- data/test/test_utils.rb +0 -188
- data/test/ts_all.rb +0 -7
- data/test/ts_all_ruby.rb +0 -5
- data/test/ts_all_zoneinfo.rb +0 -9
- data/test/tzinfo-data/tzinfo/data.rb +0 -8
- data/test/tzinfo-data/tzinfo/data/definitions/America/Argentina/Buenos_Aires.rb +0 -89
- data/test/tzinfo-data/tzinfo/data/definitions/America/New_York.rb +0 -315
- data/test/tzinfo-data/tzinfo/data/definitions/Australia/Melbourne.rb +0 -218
- data/test/tzinfo-data/tzinfo/data/definitions/EST.rb +0 -19
- data/test/tzinfo-data/tzinfo/data/definitions/Etc/GMT__m__1.rb +0 -21
- data/test/tzinfo-data/tzinfo/data/definitions/Etc/GMT__p__1.rb +0 -21
- data/test/tzinfo-data/tzinfo/data/definitions/Etc/UTC.rb +0 -21
- data/test/tzinfo-data/tzinfo/data/definitions/Europe/Amsterdam.rb +0 -261
- data/test/tzinfo-data/tzinfo/data/definitions/Europe/Andorra.rb +0 -186
- data/test/tzinfo-data/tzinfo/data/definitions/Europe/London.rb +0 -321
- data/test/tzinfo-data/tzinfo/data/definitions/Europe/Paris.rb +0 -265
- data/test/tzinfo-data/tzinfo/data/definitions/Europe/Prague.rb +0 -220
- data/test/tzinfo-data/tzinfo/data/definitions/UTC.rb +0 -16
- data/test/tzinfo-data/tzinfo/data/indexes/countries.rb +0 -927
- data/test/tzinfo-data/tzinfo/data/indexes/timezones.rb +0 -596
- data/test/tzinfo-data/tzinfo/data/version.rb +0 -14
- data/test/zoneinfo/America/Argentina/Buenos_Aires +0 -0
- data/test/zoneinfo/America/New_York +0 -0
- data/test/zoneinfo/Australia/Melbourne +0 -0
- data/test/zoneinfo/EST +0 -0
- data/test/zoneinfo/Etc/UTC +0 -0
- data/test/zoneinfo/Europe/Amsterdam +0 -0
- data/test/zoneinfo/Europe/Andorra +0 -0
- data/test/zoneinfo/Europe/London +0 -0
- data/test/zoneinfo/Europe/Paris +0 -0
- data/test/zoneinfo/Europe/Prague +0 -0
- data/test/zoneinfo/Factory +0 -0
- data/test/zoneinfo/iso3166.tab +0 -275
- data/test/zoneinfo/leapseconds +0 -61
- data/test/zoneinfo/posix/Europe/London +0 -0
- data/test/zoneinfo/posixrules +0 -0
- data/test/zoneinfo/right/Europe/London +0 -0
- data/test/zoneinfo/zone.tab +0 -439
- data/test/zoneinfo/zone1970.tab +0 -369
- data/tzinfo.gemspec +0 -21
@@ -1,295 +0,0 @@
|
|
1
|
-
require File.join(File.expand_path(File.dirname(__FILE__)), 'test_utils')
|
2
|
-
require 'date'
|
3
|
-
|
4
|
-
include TZInfo
|
5
|
-
|
6
|
-
class TCTimezoneTransitionDefinition < Minitest::Test
|
7
|
-
def test_initialize_timestamp_only
|
8
|
-
assert_nothing_raised do
|
9
|
-
TimezoneTransitionDefinition.new(TimezoneOffset.new(3600, 3600, :TDT),
|
10
|
-
TimezoneOffset.new(3600, 0, :TST), 1148949080)
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
def test_initialize_timestamp_and_datetime
|
15
|
-
assert_nothing_raised do
|
16
|
-
TimezoneTransitionDefinition.new(TimezoneOffset.new(3600, 3600, :TDT),
|
17
|
-
TimezoneOffset.new(3600, 0, :TST), 1148949080, 5300392727, 2160)
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
def test_initialize_datetime_only
|
22
|
-
assert_nothing_raised do
|
23
|
-
TimezoneTransitionDefinition.new(TimezoneOffset.new(3600, 3600, :TDT),
|
24
|
-
TimezoneOffset.new(3600, 0, :TST), 5300392727, 2160)
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
def test_at
|
29
|
-
t1 = TimezoneTransitionDefinition.new(TimezoneOffset.new(3600, 3600, :TDT),
|
30
|
-
TimezoneOffset.new(3600, 0, :TST), 1148949080)
|
31
|
-
t2 = TimezoneTransitionDefinition.new(TimezoneOffset.new(3600, 3600, :TDT),
|
32
|
-
TimezoneOffset.new(3600, 0, :TST), 5300392727, 2160)
|
33
|
-
t3 = TimezoneTransitionDefinition.new(TimezoneOffset.new(3600, 3600, :TDT),
|
34
|
-
TimezoneOffset.new(3600, 0, :TST), 1148949080, 5300392727, 2160)
|
35
|
-
|
36
|
-
assert(TimeOrDateTime.new(1148949080).eql?(t1.at))
|
37
|
-
assert(TimeOrDateTime.new(DateTime.new(2006, 5, 30, 0, 31, 20)).eql?(t2.at))
|
38
|
-
assert(TimeOrDateTime.new(1148949080).eql?(t3.at))
|
39
|
-
end
|
40
|
-
|
41
|
-
def test_at_before_negative_32_bit
|
42
|
-
t = TimezoneTransitionDefinition.new(TimezoneOffset.new(3600, 3600, :TDT),
|
43
|
-
TimezoneOffset.new(3600, 0, :TST), -2147483649, 69573092117, 28800)
|
44
|
-
|
45
|
-
if RubyCoreSupport.time_supports_negative && RubyCoreSupport.time_supports_64bit
|
46
|
-
assert(TimeOrDateTime.new(-2147483649).eql?(t.at))
|
47
|
-
else
|
48
|
-
assert(TimeOrDateTime.new(DateTime.new(1901, 12, 13, 20, 45, 51)).eql?(t.at))
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
def test_at_before_epoch
|
53
|
-
t = TimezoneTransitionDefinition.new(TimezoneOffset.new(3600, 3600, :TDT),
|
54
|
-
TimezoneOffset.new(3600, 0, :TST), -1, 210866759999, 86400)
|
55
|
-
|
56
|
-
if RubyCoreSupport.time_supports_negative
|
57
|
-
assert(TimeOrDateTime.new(-1).eql?(t.at))
|
58
|
-
else
|
59
|
-
assert(TimeOrDateTime.new(DateTime.new(1969, 12, 31, 23, 59, 59)).eql?(t.at))
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
def test_at_after_32bit
|
64
|
-
t = TimezoneTransitionDefinition.new(TimezoneOffset.new(3600, 3600, :TDT),
|
65
|
-
TimezoneOffset.new(3600, 0, :TST), 2147483648, 3328347557, 1350)
|
66
|
-
|
67
|
-
if RubyCoreSupport.time_supports_64bit
|
68
|
-
assert(TimeOrDateTime.new(2147483648).eql?(t.at))
|
69
|
-
else
|
70
|
-
assert(TimeOrDateTime.new(DateTime.new(2038, 1, 19, 3, 14, 8)).eql?(t.at))
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
def test_at_after_freeze
|
75
|
-
t1 = TimezoneTransitionDefinition.new(TimezoneOffset.new(3600, 3600, :TDT),
|
76
|
-
TimezoneOffset.new(3600, 0, :TST), 1148949080)
|
77
|
-
t2 = TimezoneTransitionDefinition.new(TimezoneOffset.new(3600, 3600, :TDT),
|
78
|
-
TimezoneOffset.new(3600, 0, :TST), 5300392727, 2160)
|
79
|
-
t1.freeze
|
80
|
-
t2.freeze
|
81
|
-
assert(TimeOrDateTime.new(1148949080).eql?(t1.at))
|
82
|
-
assert(TimeOrDateTime.new(DateTime.new(2006, 5, 30, 0, 31, 20)).eql?(t2.at))
|
83
|
-
end
|
84
|
-
|
85
|
-
def test_eql_timestamp
|
86
|
-
t1 = TimezoneTransitionDefinition.new(TimezoneOffset.new(3600, 3600, :TDT),
|
87
|
-
TimezoneOffset.new(3600, 0, :TST), 1148949080)
|
88
|
-
t2 = TimezoneTransitionDefinition.new(TimezoneOffset.new(3600, 3600, :TDT),
|
89
|
-
TimezoneOffset.new(3600, 0, :TST), 1148949080)
|
90
|
-
t3 = TimezoneTransitionDefinition.new(TimezoneOffset.new(3600, 3600, :TDT),
|
91
|
-
TimezoneOffset.new(3600, 0, :TST), 5300392727, 2160)
|
92
|
-
t4 = TimezoneTransitionDefinition.new(TimezoneOffset.new(3600, 3600, :TDT),
|
93
|
-
TimezoneOffset.new(3600, 0, :TST), 1148949080, 5300392727, 2160)
|
94
|
-
t5 = TimezoneTransitionDefinition.new(TimezoneOffset.new(3600, 3600, :TDT),
|
95
|
-
TimezoneOffset.new(3600, 0, :TST), 1148949081)
|
96
|
-
t6 = TimezoneTransitionDefinition.new(TimezoneOffset.new(3601, 3600, :TDT),
|
97
|
-
TimezoneOffset.new(3600, 0, :TST), 1148949080)
|
98
|
-
t7 = TimezoneTransitionDefinition.new(TimezoneOffset.new(3600, 3600, :TDT),
|
99
|
-
TimezoneOffset.new(3601, 0, :TST), 1148949080)
|
100
|
-
|
101
|
-
assert_equal(true, t1.eql?(t1))
|
102
|
-
assert_equal(true, t1.eql?(t2))
|
103
|
-
assert_equal(false, t1.eql?(t3))
|
104
|
-
assert_equal(true, t1.eql?(t4))
|
105
|
-
assert_equal(false, t1.eql?(t5))
|
106
|
-
assert_equal(false, t1.eql?(t6))
|
107
|
-
assert_equal(false, t1.eql?(t7))
|
108
|
-
assert_equal(false, t1.eql?(Object.new))
|
109
|
-
end
|
110
|
-
|
111
|
-
def test_eql_datetime
|
112
|
-
t1 = TimezoneTransitionDefinition.new(TimezoneOffset.new(3600, 3600, :TDT),
|
113
|
-
TimezoneOffset.new(3600, 0, :TST), 5300392727, 2160)
|
114
|
-
t2 = TimezoneTransitionDefinition.new(TimezoneOffset.new(3600, 3600, :TDT),
|
115
|
-
TimezoneOffset.new(3600, 0, :TST), 5300392727, 2160)
|
116
|
-
t3 = TimezoneTransitionDefinition.new(TimezoneOffset.new(3600, 3600, :TDT),
|
117
|
-
TimezoneOffset.new(3600, 0, :TST), 1148949080)
|
118
|
-
t4 = TimezoneTransitionDefinition.new(TimezoneOffset.new(3600, 3600, :TDT),
|
119
|
-
TimezoneOffset.new(3600, 0, :TST), 1148949080, 5300392727, 2160)
|
120
|
-
t5 = TimezoneTransitionDefinition.new(TimezoneOffset.new(3600, 3600, :TDT),
|
121
|
-
TimezoneOffset.new(3600, 0, :TST), 7852433803, 3200)
|
122
|
-
t6 = TimezoneTransitionDefinition.new(TimezoneOffset.new(3601, 3600, :TDT),
|
123
|
-
TimezoneOffset.new(3600, 0, :TST), 5300392727, 2160)
|
124
|
-
t7 = TimezoneTransitionDefinition.new(TimezoneOffset.new(3600, 3600, :TDT),
|
125
|
-
TimezoneOffset.new(3601, 0, :TST), 5300392727, 2160)
|
126
|
-
|
127
|
-
assert_equal(true, t1.eql?(t1))
|
128
|
-
assert_equal(true, t1.eql?(t2))
|
129
|
-
assert_equal(false, t1.eql?(t3))
|
130
|
-
assert_equal(false, t1.eql?(t4))
|
131
|
-
assert_equal(false, t1.eql?(t5))
|
132
|
-
assert_equal(false, t1.eql?(t6))
|
133
|
-
assert_equal(false, t1.eql?(t7))
|
134
|
-
assert_equal(false, t1.eql?(Object.new))
|
135
|
-
end
|
136
|
-
|
137
|
-
def test_eql_timestamp_and_datetime
|
138
|
-
t1 = TimezoneTransitionDefinition.new(TimezoneOffset.new(3600, 3600, :TDT),
|
139
|
-
TimezoneOffset.new(3600, 0, :TST), 1148949080, 5300392727, 2160)
|
140
|
-
t2 = TimezoneTransitionDefinition.new(TimezoneOffset.new(3600, 3600, :TDT),
|
141
|
-
TimezoneOffset.new(3600, 0, :TST), 1148949080, 5300392727, 2160)
|
142
|
-
t3 = TimezoneTransitionDefinition.new(TimezoneOffset.new(3600, 3600, :TDT),
|
143
|
-
TimezoneOffset.new(3600, 0, :TST), 1148949080)
|
144
|
-
t4 = TimezoneTransitionDefinition.new(TimezoneOffset.new(3600, 3600, :TDT),
|
145
|
-
TimezoneOffset.new(3600, 0, :TST), 5300392727, 2160)
|
146
|
-
t5 = TimezoneTransitionDefinition.new(TimezoneOffset.new(3600, 3600, :TDT),
|
147
|
-
TimezoneOffset.new(3600, 0, :TST), 1148952681, 7852433803, 3200)
|
148
|
-
t6 = TimezoneTransitionDefinition.new(TimezoneOffset.new(3601, 3600, :TDT),
|
149
|
-
TimezoneOffset.new(3600, 0, :TST), 1148949080, 5300392727, 2160)
|
150
|
-
t7 = TimezoneTransitionDefinition.new(TimezoneOffset.new(3600, 3600, :TDT),
|
151
|
-
TimezoneOffset.new(3601, 0, :TST), 1148949080, 5300392727, 2160)
|
152
|
-
|
153
|
-
assert_equal(true, t1.eql?(t1))
|
154
|
-
assert_equal(true, t1.eql?(t2))
|
155
|
-
assert_equal(true, t1.eql?(t3))
|
156
|
-
assert_equal(false, t1.eql?(t4))
|
157
|
-
assert_equal(false, t1.eql?(t5))
|
158
|
-
assert_equal(false, t1.eql?(t6))
|
159
|
-
assert_equal(false, t1.eql?(t7))
|
160
|
-
assert_equal(false, t1.eql?(Object.new))
|
161
|
-
end
|
162
|
-
|
163
|
-
def test_eql_timestamp_and_datetime_before_negative_32bit
|
164
|
-
t1 = TimezoneTransitionDefinition.new(TimezoneOffset.new(3600, 3600, :TDT),
|
165
|
-
TimezoneOffset.new(3600, 0, :TST), -2147483649, 69573092117, 28800)
|
166
|
-
t2 = TimezoneTransitionDefinition.new(TimezoneOffset.new(3600, 3600, :TDT),
|
167
|
-
TimezoneOffset.new(3600, 0, :TST), -2147483649, 69573092117, 28800)
|
168
|
-
t3 = TimezoneTransitionDefinition.new(TimezoneOffset.new(3600, 3600, :TDT),
|
169
|
-
TimezoneOffset.new(3600, 0, :TST), -2147483649)
|
170
|
-
t4 = TimezoneTransitionDefinition.new(TimezoneOffset.new(3600, 3600, :TDT),
|
171
|
-
TimezoneOffset.new(3600, 0, :TST), 69573092117, 28800)
|
172
|
-
|
173
|
-
assert_equal(true, t1.eql?(t1))
|
174
|
-
assert_equal(true, t1.eql?(t2))
|
175
|
-
|
176
|
-
if RubyCoreSupport.time_supports_negative && RubyCoreSupport.time_supports_64bit
|
177
|
-
assert_equal(true, t1.eql?(t3))
|
178
|
-
assert_equal(false, t1.eql?(t4))
|
179
|
-
assert_equal(true, t3.eql?(t1))
|
180
|
-
assert_equal(false, t4.eql?(t1))
|
181
|
-
else
|
182
|
-
assert_equal(false, t1.eql?(t3))
|
183
|
-
assert_equal(true, t1.eql?(t4))
|
184
|
-
assert_equal(false, t3.eql?(t1))
|
185
|
-
assert_equal(true, t4.eql?(t1))
|
186
|
-
end
|
187
|
-
end
|
188
|
-
|
189
|
-
def test_eql_timestamp_and_datetime_before_epoch
|
190
|
-
t1 = TimezoneTransitionDefinition.new(TimezoneOffset.new(3600, 3600, :TDT),
|
191
|
-
TimezoneOffset.new(3600, 0, :TST), -1, 210866759999, 86400)
|
192
|
-
t2 = TimezoneTransitionDefinition.new(TimezoneOffset.new(3600, 3600, :TDT),
|
193
|
-
TimezoneOffset.new(3600, 0, :TST), -1, 210866759999, 86400)
|
194
|
-
t3 = TimezoneTransitionDefinition.new(TimezoneOffset.new(3600, 3600, :TDT),
|
195
|
-
TimezoneOffset.new(3600, 0, :TST), -1)
|
196
|
-
t4 = TimezoneTransitionDefinition.new(TimezoneOffset.new(3600, 3600, :TDT),
|
197
|
-
TimezoneOffset.new(3600, 0, :TST), 210866759999, 86400)
|
198
|
-
|
199
|
-
assert_equal(true, t1.eql?(t1))
|
200
|
-
assert_equal(true, t1.eql?(t2))
|
201
|
-
|
202
|
-
if RubyCoreSupport.time_supports_negative
|
203
|
-
assert_equal(true, t1.eql?(t3))
|
204
|
-
assert_equal(false, t1.eql?(t4))
|
205
|
-
assert_equal(true, t3.eql?(t1))
|
206
|
-
assert_equal(false, t4.eql?(t1))
|
207
|
-
else
|
208
|
-
assert_equal(false, t1.eql?(t3))
|
209
|
-
assert_equal(true, t1.eql?(t4))
|
210
|
-
assert_equal(false, t3.eql?(t1))
|
211
|
-
assert_equal(true, t4.eql?(t1))
|
212
|
-
end
|
213
|
-
end
|
214
|
-
|
215
|
-
def test_eql_timestamp_and_datetime_after_32bit
|
216
|
-
t1 = TimezoneTransitionDefinition.new(TimezoneOffset.new(3600, 3600, :TDT),
|
217
|
-
TimezoneOffset.new(3600, 0, :TST), 2147483648, 3328347557, 1350)
|
218
|
-
t2 = TimezoneTransitionDefinition.new(TimezoneOffset.new(3600, 3600, :TDT),
|
219
|
-
TimezoneOffset.new(3600, 0, :TST), 2147483648, 3328347557, 1350)
|
220
|
-
t3 = TimezoneTransitionDefinition.new(TimezoneOffset.new(3600, 3600, :TDT),
|
221
|
-
TimezoneOffset.new(3600, 0, :TST), 2147483648)
|
222
|
-
t4 = TimezoneTransitionDefinition.new(TimezoneOffset.new(3600, 3600, :TDT),
|
223
|
-
TimezoneOffset.new(3600, 0, :TST), 3328347557, 1350)
|
224
|
-
|
225
|
-
assert_equal(true, t1.eql?(t1))
|
226
|
-
assert_equal(true, t1.eql?(t2))
|
227
|
-
|
228
|
-
if RubyCoreSupport.time_supports_64bit
|
229
|
-
assert_equal(true, t1.eql?(t3))
|
230
|
-
assert_equal(false, t1.eql?(t4))
|
231
|
-
assert_equal(true, t3.eql?(t1))
|
232
|
-
assert_equal(false, t4.eql?(t1))
|
233
|
-
else
|
234
|
-
assert_equal(false, t1.eql?(t3))
|
235
|
-
assert_equal(true, t1.eql?(t4))
|
236
|
-
assert_equal(false, t3.eql?(t1))
|
237
|
-
assert_equal(true, t4.eql?(t1))
|
238
|
-
end
|
239
|
-
end
|
240
|
-
|
241
|
-
def test_hash
|
242
|
-
t1 = TimezoneTransitionDefinition.new(TimezoneOffset.new(3600, 3600, :TDT),
|
243
|
-
TimezoneOffset.new(3600, 0, :TST), 1148949080)
|
244
|
-
t2 = TimezoneTransitionDefinition.new(TimezoneOffset.new(3600, 3600, :TDT),
|
245
|
-
TimezoneOffset.new(3600, 0, :TST), 5300392727, 2160)
|
246
|
-
t3 = TimezoneTransitionDefinition.new(TimezoneOffset.new(3600, 3600, :TDT),
|
247
|
-
TimezoneOffset.new(3600, 0, :TST), 1148949080, 5300392727, 2160)
|
248
|
-
t4 = TimezoneTransitionDefinition.new(TimezoneOffset.new(3600, 3600, :TDT),
|
249
|
-
TimezoneOffset.new(3600, 0, :TST), -2147483649, 69573092117, 28800)
|
250
|
-
t5 = TimezoneTransitionDefinition.new(TimezoneOffset.new(3600, 3600, :TDT),
|
251
|
-
TimezoneOffset.new(3600, 0, :TST), -1, 210866759999, 86400)
|
252
|
-
t6 = TimezoneTransitionDefinition.new(TimezoneOffset.new(3600, 3600, :TDT),
|
253
|
-
TimezoneOffset.new(3600, 0, :TST), 2147483648, 3328347557, 1350)
|
254
|
-
|
255
|
-
assert_equal(TimezoneOffset.new(3600, 3600, :TDT).hash ^
|
256
|
-
TimezoneOffset.new(3600, 0, :TST).hash ^ 1148949080.hash ^ nil.hash,
|
257
|
-
t1.hash)
|
258
|
-
assert_equal(TimezoneOffset.new(3600, 3600, :TDT).hash ^
|
259
|
-
TimezoneOffset.new(3600, 0, :TST).hash ^ 5300392727.hash ^ 2160.hash,
|
260
|
-
t2.hash)
|
261
|
-
assert_equal(TimezoneOffset.new(3600, 3600, :TDT).hash ^
|
262
|
-
TimezoneOffset.new(3600, 0, :TST).hash ^ 1148949080.hash ^ nil.hash,
|
263
|
-
t3.hash)
|
264
|
-
|
265
|
-
if RubyCoreSupport.time_supports_negative && RubyCoreSupport.time_supports_64bit
|
266
|
-
assert_equal(TimezoneOffset.new(3600, 3600, :TDT).hash ^
|
267
|
-
TimezoneOffset.new(3600, 0, :TST).hash ^ -2147483649.hash ^ nil.hash,
|
268
|
-
t4.hash)
|
269
|
-
else
|
270
|
-
assert_equal(TimezoneOffset.new(3600, 3600, :TDT).hash ^
|
271
|
-
TimezoneOffset.new(3600, 0, :TST).hash ^ 69573092117.hash ^ 28800.hash,
|
272
|
-
t4.hash)
|
273
|
-
end
|
274
|
-
|
275
|
-
if RubyCoreSupport.time_supports_negative
|
276
|
-
assert_equal(TimezoneOffset.new(3600, 3600, :TDT).hash ^
|
277
|
-
TimezoneOffset.new(3600, 0, :TST).hash ^ -1.hash ^ nil.hash,
|
278
|
-
t5.hash)
|
279
|
-
else
|
280
|
-
assert_equal(TimezoneOffset.new(3600, 3600, :TDT).hash ^
|
281
|
-
TimezoneOffset.new(3600, 0, :TST).hash ^ 210866759999.hash ^ 86400.hash,
|
282
|
-
t5.hash)
|
283
|
-
end
|
284
|
-
|
285
|
-
if RubyCoreSupport.time_supports_64bit
|
286
|
-
assert_equal(TimezoneOffset.new(3600, 3600, :TDT).hash ^
|
287
|
-
TimezoneOffset.new(3600, 0, :TST).hash ^ 2147483648.hash ^ nil.hash,
|
288
|
-
t6.hash)
|
289
|
-
else
|
290
|
-
assert_equal(TimezoneOffset.new(3600, 3600, :TDT).hash ^
|
291
|
-
TimezoneOffset.new(3600, 0, :TST).hash ^ 3328347557.hash ^ 1350.hash,
|
292
|
-
t6.hash)
|
293
|
-
end
|
294
|
-
end
|
295
|
-
end
|
data/test/tc_timezone_utc.rb
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
require File.join(File.expand_path(File.dirname(__FILE__)), 'test_utils')
|
2
|
-
|
3
|
-
include TZInfo
|
4
|
-
|
5
|
-
class TCTimezoneUTC < Minitest::Test
|
6
|
-
def test_2004
|
7
|
-
tz = Timezone.get('UTC')
|
8
|
-
|
9
|
-
assert_equal(DateTime.new(2004,1,1,0,0,0), tz.utc_to_local(DateTime.new(2004,1,1,0,0,0)))
|
10
|
-
assert_equal(DateTime.new(2004,12,31,23,59,59), tz.utc_to_local(DateTime.new(2004,12,31,23,59,59)))
|
11
|
-
|
12
|
-
assert_equal(DateTime.new(2004,1,1,0,0,0), tz.local_to_utc(DateTime.new(2004,1,1,0,0,0)))
|
13
|
-
assert_equal(DateTime.new(2004,12,31,23,59,59), tz.local_to_utc(DateTime.new(2004,12,31,23,59,59)))
|
14
|
-
|
15
|
-
assert_equal(:UTC, tz.period_for_utc(DateTime.new(2004,1,1,0,0,0)).zone_identifier)
|
16
|
-
assert_equal(:UTC, tz.period_for_utc(DateTime.new(2004,12,31,23,59,59)).zone_identifier)
|
17
|
-
|
18
|
-
assert_equal(:UTC, tz.period_for_local(DateTime.new(2004,1,1,0,0,0)).zone_identifier)
|
19
|
-
assert_equal(:UTC, tz.period_for_local(DateTime.new(2004,12,31,23,59,59)).zone_identifier)
|
20
|
-
|
21
|
-
assert_equal(0, tz.period_for_utc(DateTime.new(2004,1,1,0,0,0)).utc_total_offset)
|
22
|
-
assert_equal(0, tz.period_for_utc(DateTime.new(2004,12,31,23,59,59)).utc_total_offset)
|
23
|
-
|
24
|
-
assert_equal(0, tz.period_for_local(DateTime.new(2004,1,1,0,0,0)).utc_total_offset)
|
25
|
-
assert_equal(0, tz.period_for_local(DateTime.new(2004,12,31,23,59,59)).utc_total_offset)
|
26
|
-
end
|
27
|
-
end
|
@@ -1,433 +0,0 @@
|
|
1
|
-
require File.join(File.expand_path(File.dirname(__FILE__)), 'test_utils')
|
2
|
-
|
3
|
-
include TZInfo
|
4
|
-
|
5
|
-
class TCTransitionDataTimezoneInfo < Minitest::Test
|
6
|
-
|
7
|
-
def test_identifier
|
8
|
-
dti = TransitionDataTimezoneInfo.new('Test/Zone')
|
9
|
-
assert_equal('Test/Zone', dti.identifier)
|
10
|
-
end
|
11
|
-
|
12
|
-
def test_offset
|
13
|
-
dti = TransitionDataTimezoneInfo.new('Test/Zone')
|
14
|
-
|
15
|
-
assert_nothing_raised do
|
16
|
-
dti.offset :o1, -18000, 3600, :TEST
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
def test_offset_already_defined
|
21
|
-
dti = TransitionDataTimezoneInfo.new('Test/Zone')
|
22
|
-
dti.offset :o1, 3600, 0, :TEST
|
23
|
-
dti.offset :o2, 1800, 0, :TEST2
|
24
|
-
|
25
|
-
assert_raises(ArgumentError) { dti.offset :o1, 3600, 3600, :TESTD }
|
26
|
-
end
|
27
|
-
|
28
|
-
def test_transition_timestamp
|
29
|
-
dti = TransitionDataTimezoneInfo.new('Test/Zone')
|
30
|
-
dti.offset :o1, -18000, 3600, :TEST
|
31
|
-
|
32
|
-
assert_nothing_raised do
|
33
|
-
dti.transition 2006, 6, :o1, 1149368400
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
def test_transition_datetime
|
38
|
-
dti = TransitionDataTimezoneInfo.new('Test/Zone')
|
39
|
-
dti.offset :o1, -18000, 3600, :TEST
|
40
|
-
|
41
|
-
assert_nothing_raised do
|
42
|
-
dti.transition 2006, 6, :o1, 19631123, 8
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
def test_transition_timestamp_and_datetime
|
47
|
-
dti = TransitionDataTimezoneInfo.new('Test/Zone')
|
48
|
-
dti.offset :o1, -18000, 3600, :TEST
|
49
|
-
|
50
|
-
assert_nothing_raised do
|
51
|
-
dti.transition 2006, 6, :o1, 1149368400, 19631123, 8
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
def test_transition_invalid_offset
|
56
|
-
dti = TransitionDataTimezoneInfo.new('Test/Zone')
|
57
|
-
dti.offset :o1, -18000, 3600, :TEST
|
58
|
-
|
59
|
-
dti.transition 2006, 6, :o1, 1149368400
|
60
|
-
|
61
|
-
assert_raises(ArgumentError) { dti.transition 2006, 6, :o2, 1149454800 }
|
62
|
-
end
|
63
|
-
|
64
|
-
def test_transition_no_offsets
|
65
|
-
dti = TransitionDataTimezoneInfo.new('Test/Zone')
|
66
|
-
|
67
|
-
assert_raises(ArgumentError) { dti.transition 2006, 6, :o1, 1149368400 }
|
68
|
-
end
|
69
|
-
|
70
|
-
def test_transition_invalid_order_month
|
71
|
-
dti = TransitionDataTimezoneInfo.new('Test/Zone')
|
72
|
-
dti.offset :o1, -18000, 3600, :TEST
|
73
|
-
|
74
|
-
dti.transition 2006, 6, :o1, 1149368400
|
75
|
-
|
76
|
-
assert_raises(ArgumentError) { dti.transition 2006, 5, :o2, 1146690000 }
|
77
|
-
end
|
78
|
-
|
79
|
-
def test_transition_invalid_order_year
|
80
|
-
dti = TransitionDataTimezoneInfo.new('Test/Zone')
|
81
|
-
dti.offset :o1, -18000, 3600, :TEST
|
82
|
-
|
83
|
-
dti.transition 2006, 6, :o1, 1149368400
|
84
|
-
|
85
|
-
assert_raises(ArgumentError) { dti.transition 2005, 7, :o2, 1120424400 }
|
86
|
-
end
|
87
|
-
|
88
|
-
def test_period_for_utc
|
89
|
-
dti = TransitionDataTimezoneInfo.new('Test/Zone')
|
90
|
-
dti.offset :o1, -17900, 0, :TESTLMT
|
91
|
-
dti.offset :o2, -18000, 3600, :TESTD
|
92
|
-
dti.offset :o3, -18000, 0, :TESTS
|
93
|
-
dti.offset :o4, -21600, 3600, :TESTD
|
94
|
-
|
95
|
-
dti.transition 2000, 4, :o2, Time.utc(2000, 4,1,1,0,0).to_i
|
96
|
-
dti.transition 2000, 10, :o3, Time.utc(2000,10,1,1,0,0).to_i
|
97
|
-
dti.transition 2001, 3, :o2, 58847269, 24 # (2001, 3,1,1,0,0)
|
98
|
-
dti.transition 2001, 4, :o4, Time.utc(2001, 4,1,1,0,0).to_i, 58848013, 24
|
99
|
-
dti.transition 2001, 10, :o3, Time.utc(2001,10,1,1,0,0).to_i
|
100
|
-
dti.transition 2002, 10, :o3, Time.utc(2002,10,1,1,0,0).to_i
|
101
|
-
dti.transition 2003, 2, :o2, Time.utc(2003, 2,1,1,0,0).to_i
|
102
|
-
dti.transition 2003, 3, :o3, Time.utc(2003, 3,1,1,0,0).to_i
|
103
|
-
|
104
|
-
o1 = TimezoneOffset.new(-17900, 0, :TESTLMT)
|
105
|
-
o2 = TimezoneOffset.new(-18000, 3600, :TESTD)
|
106
|
-
o3 = TimezoneOffset.new(-18000, 0, :TESTS)
|
107
|
-
o4 = TimezoneOffset.new(-21600, 3600, :TESTD)
|
108
|
-
|
109
|
-
t1 = TimezoneTransitionDefinition.new(o2, o1, Time.utc(2000, 4,1,1,0,0).to_i)
|
110
|
-
t2 = TimezoneTransitionDefinition.new(o3, o2, Time.utc(2000,10,1,1,0,0).to_i)
|
111
|
-
t3 = TimezoneTransitionDefinition.new(o2, o3, Time.utc(2001, 3,1,1,0,0).to_i)
|
112
|
-
t4 = TimezoneTransitionDefinition.new(o4, o2, Time.utc(2001, 4,1,1,0,0).to_i)
|
113
|
-
t5 = TimezoneTransitionDefinition.new(o3, o4, Time.utc(2001,10,1,1,0,0).to_i)
|
114
|
-
t6 = TimezoneTransitionDefinition.new(o3, o3, Time.utc(2002,10,1,1,0,0).to_i)
|
115
|
-
t7 = TimezoneTransitionDefinition.new(o2, o3, Time.utc(2003, 2,1,1,0,0).to_i)
|
116
|
-
t8 = TimezoneTransitionDefinition.new(o3, o2, Time.utc(2003, 3,1,1,0,0).to_i)
|
117
|
-
|
118
|
-
assert_equal(TimezonePeriod.new(nil, t1), dti.period_for_utc(DateTime.new(1960, 1,1,1, 0, 0)))
|
119
|
-
assert_equal(TimezonePeriod.new(nil, t1), dti.period_for_utc(DateTime.new(1999,12,1,0, 0, 0)))
|
120
|
-
assert_equal(TimezonePeriod.new(nil, t1), dti.period_for_utc(Time.utc( 2000, 4,1,0,59,59)))
|
121
|
-
assert_equal(TimezonePeriod.new(t1, t2), dti.period_for_utc(DateTime.new(2000, 4,1,1, 0, 0)))
|
122
|
-
assert_equal(TimezonePeriod.new(t1, t2), dti.period_for_utc(Time.utc( 2000,10,1,0,59,59).to_i))
|
123
|
-
assert_equal(TimezonePeriod.new(t2, t3), dti.period_for_utc(Time.utc( 2000,10,1,1, 0, 0)))
|
124
|
-
assert_equal(TimezonePeriod.new(t2, t3), dti.period_for_utc(Time.utc( 2001, 3,1,0,59,59)))
|
125
|
-
assert_equal(TimezonePeriod.new(t3, t4), dti.period_for_utc(Time.utc( 2001, 3,1,1, 0, 0)))
|
126
|
-
assert_equal(TimezonePeriod.new(t3, t4), dti.period_for_utc(Time.utc( 2001, 4,1,0,59,59)))
|
127
|
-
assert_equal(TimezonePeriod.new(t4, t5), dti.period_for_utc(Time.utc( 2001, 4,1,1, 0, 0)))
|
128
|
-
assert_equal(TimezonePeriod.new(t4, t5), dti.period_for_utc(Time.utc( 2001,10,1,0,59,59)))
|
129
|
-
assert_equal(TimezonePeriod.new(t5, t6), dti.period_for_utc(Time.utc( 2001,10,1,1, 0, 0)))
|
130
|
-
assert_equal(TimezonePeriod.new(t5, t6), dti.period_for_utc(Time.utc( 2002, 2,1,1, 0, 0)))
|
131
|
-
assert_equal(TimezonePeriod.new(t5, t6), dti.period_for_utc(Time.utc( 2002,10,1,0,59,59)))
|
132
|
-
assert_equal(TimezonePeriod.new(t6, t7), dti.period_for_utc(Time.utc( 2002,10,1,1, 0, 0)))
|
133
|
-
assert_equal(TimezonePeriod.new(t6, t7), dti.period_for_utc(Time.utc( 2003, 2,1,0,59,59)))
|
134
|
-
assert_equal(TimezonePeriod.new(t7, t8), dti.period_for_utc(Time.utc( 2003, 2,1,1, 0, 0)))
|
135
|
-
assert_equal(TimezonePeriod.new(t7, t8), dti.period_for_utc(Time.utc( 2003, 3,1,0,59,59)))
|
136
|
-
assert_equal(TimezonePeriod.new(t8, nil), dti.period_for_utc(Time.utc( 2003, 3,1,1, 0, 0)))
|
137
|
-
assert_equal(TimezonePeriod.new(t8, nil), dti.period_for_utc(Time.utc( 2004, 1,1,1, 0, 0)))
|
138
|
-
assert_equal(TimezonePeriod.new(t8, nil), dti.period_for_utc(DateTime.new(2050, 1,1,1, 0, 0)))
|
139
|
-
end
|
140
|
-
|
141
|
-
def test_period_for_utc_no_transitions
|
142
|
-
dti = TransitionDataTimezoneInfo.new('Test/Zone')
|
143
|
-
dti.offset :o1, -17900, 0, :TESTLMT
|
144
|
-
dti.offset :o2, -18000, 0, :TEST
|
145
|
-
|
146
|
-
o1 = TimezoneOffset.new(-17900, 0, :TESTLMT)
|
147
|
-
|
148
|
-
assert_equal(TimezonePeriod.new(nil, nil, o1), dti.period_for_utc(DateTime.new(2005,1,1,0,0,0)))
|
149
|
-
assert_equal(TimezonePeriod.new(nil, nil, o1), dti.period_for_utc(Time.utc(2005,1,1,0,0,0)))
|
150
|
-
assert_equal(TimezonePeriod.new(nil, nil, o1), dti.period_for_utc(Time.utc(2005,1,1,0,0,0).to_i))
|
151
|
-
end
|
152
|
-
|
153
|
-
def test_period_for_utc_no_offsets
|
154
|
-
dti = TransitionDataTimezoneInfo.new('Test/Zone')
|
155
|
-
|
156
|
-
assert_raises(NoOffsetsDefined) { dti.period_for_utc(DateTime.new(2005,1,1,0,0,0)) }
|
157
|
-
assert_raises(NoOffsetsDefined) { dti.period_for_utc(Time.utc(2005,1,1,0,0,0)) }
|
158
|
-
assert_raises(NoOffsetsDefined) { dti.period_for_utc(Time.utc(2005,1,1,0,0,0).to_i) }
|
159
|
-
end
|
160
|
-
|
161
|
-
def test_periods_for_local
|
162
|
-
dti = TransitionDataTimezoneInfo.new('Test/Zone')
|
163
|
-
dti.offset :o1, -17900, 0, :TESTLMT
|
164
|
-
dti.offset :o2, -18000, 3600, :TESTD
|
165
|
-
dti.offset :o3, -18000, 0, :TESTS
|
166
|
-
dti.offset :o4, -21600, 3600, :TESTD
|
167
|
-
|
168
|
-
dti.transition 2000, 4, :o2, 58839277, 24 # 2000,4,2,1,0,0
|
169
|
-
dti.transition 2000, 10, :o3, Time.utc(2000,10,2,1,0,0).to_i, 58843669, 24
|
170
|
-
dti.transition 2001, 3, :o2, Time.utc(2001, 3,2,1,0,0).to_i
|
171
|
-
dti.transition 2001, 4, :o4, Time.utc(2001, 4,2,1,0,0).to_i
|
172
|
-
dti.transition 2001, 10, :o3, Time.utc(2001,10,2,1,0,0).to_i
|
173
|
-
dti.transition 2002, 10, :o3, 58861189, 24 # 2002,10,2,1,0,0
|
174
|
-
dti.transition 2003, 2, :o2, Time.utc(2003, 2,2,1,0,0).to_i
|
175
|
-
|
176
|
-
o1 = TimezoneOffset.new(-17900, 0, :TESTLMT)
|
177
|
-
o2 = TimezoneOffset.new(-18000, 3600, :TESTD)
|
178
|
-
o3 = TimezoneOffset.new(-18000, 0, :TESTS)
|
179
|
-
o4 = TimezoneOffset.new(-21600, 3600, :TESTD)
|
180
|
-
|
181
|
-
t1 = TimezoneTransitionDefinition.new(o2, o1, Time.utc(2000, 4,2,1,0,0).to_i)
|
182
|
-
t2 = TimezoneTransitionDefinition.new(o3, o2, Time.utc(2000,10,2,1,0,0).to_i)
|
183
|
-
t3 = TimezoneTransitionDefinition.new(o2, o3, Time.utc(2001, 3,2,1,0,0).to_i)
|
184
|
-
t4 = TimezoneTransitionDefinition.new(o4, o2, Time.utc(2001, 4,2,1,0,0).to_i)
|
185
|
-
t5 = TimezoneTransitionDefinition.new(o3, o4, Time.utc(2001,10,2,1,0,0).to_i)
|
186
|
-
t6 = TimezoneTransitionDefinition.new(o3, o3, Time.utc(2002,10,2,1,0,0).to_i)
|
187
|
-
t7 = TimezoneTransitionDefinition.new(o2, o3, Time.utc(2003, 2,2,1,0,0).to_i)
|
188
|
-
|
189
|
-
|
190
|
-
assert_equal([TimezonePeriod.new(nil, t1)], dti.periods_for_local(DateTime.new(1960, 1, 1, 1, 0, 0)))
|
191
|
-
assert_equal([TimezonePeriod.new(nil, t1)], dti.periods_for_local(DateTime.new(1999,12, 1, 0, 0, 0)))
|
192
|
-
assert_equal([TimezonePeriod.new(nil, t1)], dti.periods_for_local(Time.utc( 2000, 1, 1,10, 0, 0)))
|
193
|
-
assert_equal([TimezonePeriod.new(nil, t1)], dti.periods_for_local(Time.utc( 2000, 4, 1,20, 1,39)))
|
194
|
-
assert_equal([], dti.periods_for_local(Time.utc( 2000, 4, 1,20, 1,40)))
|
195
|
-
assert_equal([], dti.periods_for_local(Time.utc( 2000, 4, 1,20,59,59)))
|
196
|
-
assert_equal([TimezonePeriod.new(t1, t2)], dti.periods_for_local(Time.utc( 2000, 4, 1,21, 0, 0)))
|
197
|
-
assert_equal([TimezonePeriod.new(t1, t2)], dti.periods_for_local(DateTime.new(2000,10, 1,19,59,59)))
|
198
|
-
assert_equal([TimezonePeriod.new(t1, t2),
|
199
|
-
TimezonePeriod.new(t2, t3)], dti.periods_for_local(Time.utc( 2000,10, 1,20, 0, 0).to_i))
|
200
|
-
assert_equal([TimezonePeriod.new(t1, t2),
|
201
|
-
TimezonePeriod.new(t2, t3)], dti.periods_for_local(DateTime.new(2000,10, 1,20,59,59)))
|
202
|
-
assert_equal([TimezonePeriod.new(t2, t3)], dti.periods_for_local(Time.utc( 2000,10, 1,21, 0, 0)))
|
203
|
-
assert_equal([TimezonePeriod.new(t2, t3)], dti.periods_for_local(Time.utc( 2001, 3, 1,19,59,59)))
|
204
|
-
assert_equal([], dti.periods_for_local(Time.utc( 2001, 3, 1,20, 0, 0)))
|
205
|
-
assert_equal([], dti.periods_for_local(DateTime.new(2001, 3, 1,20, 30, 0)))
|
206
|
-
assert_equal([], dti.periods_for_local(Time.utc( 2001, 3, 1,20,59,59).to_i))
|
207
|
-
assert_equal([TimezonePeriod.new(t3, t4)], dti.periods_for_local(Time.utc( 2001, 3, 1,21, 0, 0)))
|
208
|
-
assert_equal([TimezonePeriod.new(t3, t4)], dti.periods_for_local(Time.utc( 2001, 4, 1,19,59,59)))
|
209
|
-
assert_equal([TimezonePeriod.new(t3, t4),
|
210
|
-
TimezonePeriod.new(t4, t5)], dti.periods_for_local(DateTime.new(2001, 4, 1,20, 0, 0)))
|
211
|
-
assert_equal([TimezonePeriod.new(t3, t4),
|
212
|
-
TimezonePeriod.new(t4, t5)], dti.periods_for_local(Time.utc( 2001, 4, 1,20,59,59)))
|
213
|
-
assert_equal([TimezonePeriod.new(t4, t5)], dti.periods_for_local(Time.utc( 2001, 4, 1,21, 0, 0)))
|
214
|
-
assert_equal([TimezonePeriod.new(t4, t5)], dti.periods_for_local(Time.utc( 2001,10, 1,19,59,59)))
|
215
|
-
assert_equal([TimezonePeriod.new(t5, t6)], dti.periods_for_local(Time.utc( 2001,10, 1,20, 0, 0)))
|
216
|
-
assert_equal([TimezonePeriod.new(t5, t6)], dti.periods_for_local(Time.utc( 2002, 2, 1,20, 0, 0)))
|
217
|
-
assert_equal([TimezonePeriod.new(t5, t6)], dti.periods_for_local(Time.utc( 2002,10, 1,19,59,59)))
|
218
|
-
assert_equal([TimezonePeriod.new(t6, t7)], dti.periods_for_local(Time.utc( 2002,10, 1,20, 0, 0)))
|
219
|
-
assert_equal([TimezonePeriod.new(t6, t7)], dti.periods_for_local(Time.utc( 2003, 2, 1,19,59,59)))
|
220
|
-
assert_equal([], dti.periods_for_local(Time.utc( 2003, 2, 1,20, 0, 0)))
|
221
|
-
assert_equal([], dti.periods_for_local(Time.utc( 2003, 2, 1,20,59,59)))
|
222
|
-
assert_equal([TimezonePeriod.new(t7, nil)], dti.periods_for_local(Time.utc( 2003, 2, 1,21, 0, 0)))
|
223
|
-
assert_equal([TimezonePeriod.new(t7, nil)], dti.periods_for_local(Time.utc( 2004, 2, 1,20, 0, 0)))
|
224
|
-
assert_equal([TimezonePeriod.new(t7, nil)], dti.periods_for_local(DateTime.new(2040, 2, 1,20, 0, 0)))
|
225
|
-
end
|
226
|
-
|
227
|
-
def test_periods_for_local_warsaw
|
228
|
-
dti = TransitionDataTimezoneInfo.new('Test/Europe/Warsaw')
|
229
|
-
dti.offset :o1, 5040, 0, :LMT
|
230
|
-
dti.offset :o2, 5040, 0, :WMT
|
231
|
-
dti.offset :o3, 3600, 0, :CET
|
232
|
-
dti.offset :o4, 3600, 3600, :CEST
|
233
|
-
|
234
|
-
dti.transition 1879, 12, :o2, 288925853, 120 # 1879,12,31,22,36,0
|
235
|
-
dti.transition 1915, 8, :o3, 290485733, 120 # 1915, 8, 4,22,36,0
|
236
|
-
dti.transition 1916, 4, :o4, 29051813, 12 # 1916, 4,30,22, 0,0
|
237
|
-
|
238
|
-
o1 = TimezoneOffset.new(5040, 0, :LMT)
|
239
|
-
o2 = TimezoneOffset.new(5040, 0, :WMT)
|
240
|
-
o3 = TimezoneOffset.new(3600, 0, :CET)
|
241
|
-
o4 = TimezoneOffset.new(3600, 3600, :CEST)
|
242
|
-
|
243
|
-
t1 = TimezoneTransitionDefinition.new(o2, o1, 288925853, 120)
|
244
|
-
t2 = TimezoneTransitionDefinition.new(o3, o2, 290485733, 120)
|
245
|
-
t3 = TimezoneTransitionDefinition.new(o4, o3, 29051813, 12)
|
246
|
-
|
247
|
-
assert_equal([TimezonePeriod.new(t1, t2),
|
248
|
-
TimezonePeriod.new(t2, t3)], dti.periods_for_local(DateTime.new(1915,8,4,23,40,0)))
|
249
|
-
end
|
250
|
-
|
251
|
-
def test_periods_for_local_boundary
|
252
|
-
dti = TransitionDataTimezoneInfo.new('Test/Zone')
|
253
|
-
dti.offset :o1, -3600, 0, :TESTD
|
254
|
-
dti.offset :o2, -3600, 0, :TESTS
|
255
|
-
|
256
|
-
dti.transition 2000, 7, :o2, Time.utc(2000,7,1,0,0,0).to_i
|
257
|
-
|
258
|
-
o1 = TimezoneOffset.new(-3600, 0, :TESTD)
|
259
|
-
o2 = TimezoneOffset.new(-3600, 0, :TESTS)
|
260
|
-
|
261
|
-
t1 = TimezoneTransitionDefinition.new(o2, o1, Time.utc(2000,7,1,0,0,0).to_i)
|
262
|
-
|
263
|
-
# 2000-07-01 00:00:00 UTC is 2000-06-30 23:00:00 UTC-1
|
264
|
-
# hence to find periods for local times between 2000-06-30 23:00:00
|
265
|
-
# and 2000-07-01 00:00:00 a search has to be carried out in the next half
|
266
|
-
# year to the one containing the date we are looking for
|
267
|
-
|
268
|
-
assert_equal([TimezonePeriod.new(nil, t1)], dti.periods_for_local(Time.utc(2000,6,30,22,59,59)))
|
269
|
-
assert_equal([TimezonePeriod.new(t1, nil)], dti.periods_for_local(Time.utc(2000,6,30,23, 0, 0)))
|
270
|
-
assert_equal([TimezonePeriod.new(t1, nil)], dti.periods_for_local(Time.utc(2000,7, 1, 0, 0, 0)))
|
271
|
-
end
|
272
|
-
|
273
|
-
def test_periods_for_local_no_transitions
|
274
|
-
dti = TransitionDataTimezoneInfo.new('Test/Zone')
|
275
|
-
dti.offset :o1, -17900, 0, :TESTLMT
|
276
|
-
dti.offset :o2, -18000, 0, :TEST
|
277
|
-
|
278
|
-
o1 = TimezoneOffset.new(-17900, 0, :TESTLMT)
|
279
|
-
|
280
|
-
assert_equal([TimezonePeriod.new(nil, nil, o1)], dti.periods_for_local(DateTime.new(2005,1,1,0,0,0)))
|
281
|
-
assert_equal([TimezonePeriod.new(nil, nil, o1)], dti.periods_for_local(Time.utc(2005,1,1,0,0,0)))
|
282
|
-
assert_equal([TimezonePeriod.new(nil, nil, o1)], dti.periods_for_local(Time.utc(2005,1,1,0,0,0).to_i))
|
283
|
-
end
|
284
|
-
|
285
|
-
def test_periods_for_local_no_offsets
|
286
|
-
dti = TransitionDataTimezoneInfo.new('Test/Zone')
|
287
|
-
|
288
|
-
assert_raises(NoOffsetsDefined) { dti.periods_for_local(DateTime.new(2005,1,1,0,0,0)) }
|
289
|
-
assert_raises(NoOffsetsDefined) { dti.periods_for_local(Time.utc(2005,1,1,0,0,0)) }
|
290
|
-
assert_raises(NoOffsetsDefined) { dti.periods_for_local(Time.utc(2005,1,1,0,0,0).to_i) }
|
291
|
-
end
|
292
|
-
|
293
|
-
def test_transitions_up_to
|
294
|
-
dti = TransitionDataTimezoneInfo.new('Test/Zone')
|
295
|
-
dti.offset :o1, -17900, 0, :TESTLMT
|
296
|
-
dti.offset :o2, -18000, 3600, :TESTD
|
297
|
-
dti.offset :o3, -18000, 0, :TESTS
|
298
|
-
dti.offset :o4, -21600, 3600, :TESTD
|
299
|
-
|
300
|
-
dti.transition 2010, 4, :o2, Time.utc(2010, 4,1,1,0,0).to_i
|
301
|
-
dti.transition 2010, 10, :o3, Time.utc(2010,10,1,1,0,0).to_i
|
302
|
-
dti.transition 2011, 3, :o2, 58934917, 24 # (2011, 3,1,1,0,0)
|
303
|
-
dti.transition 2011, 4, :o4, Time.utc(2011, 4,1,1,0,0).to_i, 58935661, 24
|
304
|
-
dti.transition 2011, 10, :o3, Time.utc(2011,10,1,1,0,0).to_i
|
305
|
-
|
306
|
-
o1 = TimezoneOffset.new(-17900, 0, :TESTLMT)
|
307
|
-
o2 = TimezoneOffset.new(-18000, 3600, :TESTD)
|
308
|
-
o3 = TimezoneOffset.new(-18000, 0, :TESTS)
|
309
|
-
o4 = TimezoneOffset.new(-21600, 3600, :TESTD)
|
310
|
-
|
311
|
-
t1 = TimezoneTransitionDefinition.new(o2, o1, Time.utc(2010, 4,1,1,0,0).to_i)
|
312
|
-
t2 = TimezoneTransitionDefinition.new(o3, o2, Time.utc(2010,10,1,1,0,0).to_i)
|
313
|
-
t3 = TimezoneTransitionDefinition.new(o2, o3, Time.utc(2011, 3,1,1,0,0).to_i)
|
314
|
-
t4 = TimezoneTransitionDefinition.new(o4, o2, Time.utc(2011, 4,1,1,0,0).to_i)
|
315
|
-
t5 = TimezoneTransitionDefinition.new(o3, o4, Time.utc(2011,10,1,1,0,0).to_i)
|
316
|
-
|
317
|
-
assert_equal([], dti.transitions_up_to(Time.utc(2010,4,1,1,0,0)))
|
318
|
-
assert_equal([], dti.transitions_up_to(Time.utc(2010,4,1,1,0,0), Time.utc(2000,1,1,0,0,0)))
|
319
|
-
assert_equal([t1], dti.transitions_up_to(Time.utc(2010,4,1,1,0,1)))
|
320
|
-
assert_equal([t1], dti.transitions_up_to(Time.utc(2010,4,1,1,0,1), Time.utc(2000,1,1,0,0,0)))
|
321
|
-
assert_equal([t2,t3,t4], dti.transitions_up_to(Time.utc(2011,4,1,1,0,1), Time.utc(2010,10,1,1,0,0)))
|
322
|
-
assert_equal([t2,t3,t4], dti.transitions_up_to(Time.utc(2011,10,1,1,0,0), Time.utc(2010,4,1,1,0,1)))
|
323
|
-
assert_equal([t3], dti.transitions_up_to(Time.utc(2011,4,1,1,0,0), Time.utc(2010,10,1,1,0,1)))
|
324
|
-
assert_equal([], dti.transitions_up_to(Time.utc(2011,3,1,1,0,0), Time.utc(2010,10,1,1,0,1)))
|
325
|
-
assert_equal([t1,t2,t3,t4], dti.transitions_up_to(Time.utc(2011,10,1,1,0,0)))
|
326
|
-
assert_equal([t1,t2,t3,t4,t5], dti.transitions_up_to(Time.utc(2011,10,1,1,0,1)))
|
327
|
-
assert_equal([t1,t2,t3,t4,t5], dti.transitions_up_to(Time.utc(2011,10,1,1,0,0,1)))
|
328
|
-
assert_equal([t1,t2,t3,t4,t5], dti.transitions_up_to(Time.utc(2011,10,1,1,0,1), Time.utc(2010,4,1,1,0,0)))
|
329
|
-
assert_equal([t2,t3,t4,t5], dti.transitions_up_to(Time.utc(2011,10,1,1,0,1), Time.utc(2010,4,1,1,0,1)))
|
330
|
-
assert_equal([t2,t3,t4,t5], dti.transitions_up_to(Time.utc(2011,10,1,1,0,1), Time.utc(2010,4,1,1,0,0,1)))
|
331
|
-
assert_equal([t5], dti.transitions_up_to(Time.utc(2015,1,1,0,0,0), Time.utc(2011,10,1,1,0,0)))
|
332
|
-
assert_equal([], dti.transitions_up_to(Time.utc(2015,1,1,0,0,0), Time.utc(2011,10,1,1,0,1)))
|
333
|
-
|
334
|
-
assert_equal([], dti.transitions_up_to(Time.utc(2010,4,1,1,0,0).to_i))
|
335
|
-
assert_equal([], dti.transitions_up_to(Time.utc(2010,4,1,1,0,0).to_i, Time.utc(2000,1,1,0,0,0).to_i))
|
336
|
-
assert_equal([t1], dti.transitions_up_to(Time.utc(2010,4,1,1,0,1).to_i))
|
337
|
-
assert_equal([t1], dti.transitions_up_to(Time.utc(2010,4,1,1,0,1).to_i, Time.utc(2000,1,1,0,0,0).to_i))
|
338
|
-
assert_equal([t2,t3,t4], dti.transitions_up_to(Time.utc(2011,4,1,1,0,1).to_i, Time.utc(2010,10,1,1,0,0).to_i))
|
339
|
-
assert_equal([t2,t3,t4], dti.transitions_up_to(Time.utc(2011,10,1,1,0,0).to_i, Time.utc(2010,4,1,1,0,1).to_i))
|
340
|
-
assert_equal([t3], dti.transitions_up_to(Time.utc(2011,4,1,1,0,0).to_i, Time.utc(2010,10,1,1,0,1).to_i))
|
341
|
-
assert_equal([], dti.transitions_up_to(Time.utc(2011,3,1,1,0,0).to_i, Time.utc(2010,10,1,1,0,1).to_i))
|
342
|
-
assert_equal([t1,t2,t3,t4], dti.transitions_up_to(Time.utc(2011,10,1,1,0,0).to_i))
|
343
|
-
assert_equal([t1,t2,t3,t4,t5], dti.transitions_up_to(Time.utc(2011,10,1,1,0,1).to_i))
|
344
|
-
assert_equal([t1,t2,t3,t4,t5], dti.transitions_up_to(Time.utc(2011,10,1,1,0,1).to_i, Time.utc(2010,4,1,1,0,0).to_i))
|
345
|
-
assert_equal([t2,t3,t4,t5], dti.transitions_up_to(Time.utc(2011,10,1,1,0,1).to_i, Time.utc(2010,4,1,1,0,1).to_i))
|
346
|
-
assert_equal([t5], dti.transitions_up_to(Time.utc(2015,1,1,0,0,0).to_i, Time.utc(2011,10,1,1,0,0).to_i))
|
347
|
-
assert_equal([], dti.transitions_up_to(Time.utc(2015,1,1,0,0,0).to_i, Time.utc(2011,10,1,1,0,1).to_i))
|
348
|
-
|
349
|
-
assert_equal([], dti.transitions_up_to(DateTime.new(2010,4,1,1,0,0)))
|
350
|
-
assert_equal([], dti.transitions_up_to(DateTime.new(2010,4,1,1,0,0), DateTime.new(2000,1,1,0,0,0)))
|
351
|
-
assert_equal([t1], dti.transitions_up_to(DateTime.new(2010,4,1,1,0,1)))
|
352
|
-
assert_equal([t1], dti.transitions_up_to(DateTime.new(2010,4,1,1,0,1), DateTime.new(2000,1,1,0,0,0)))
|
353
|
-
assert_equal([t2,t3,t4], dti.transitions_up_to(DateTime.new(2011,4,1,1,0,1), DateTime.new(2010,10,1,1,0,0)))
|
354
|
-
assert_equal([t2,t3,t4], dti.transitions_up_to(DateTime.new(2011,10,1,1,0,0), DateTime.new(2010,4,1,1,0,1)))
|
355
|
-
assert_equal([t3], dti.transitions_up_to(DateTime.new(2011,4,1,1,0,0), DateTime.new(2010,10,1,1,0,1)))
|
356
|
-
assert_equal([], dti.transitions_up_to(DateTime.new(2011,3,1,1,0,0), DateTime.new(2010,10,1,1,0,1)))
|
357
|
-
assert_equal([t1,t2,t3,t4], dti.transitions_up_to(DateTime.new(2011,10,1,1,0,0)))
|
358
|
-
assert_equal([t1,t2,t3,t4,t5], dti.transitions_up_to(DateTime.new(2011,10,1,1,0,1)))
|
359
|
-
assert_equal([t1,t2,t3,t4,t5], dti.transitions_up_to(DateTime.new(2011,10,1,1,0,Rational(DATETIME_RESOLUTION,1000000))))
|
360
|
-
assert_equal([t1,t2,t3,t4,t5], dti.transitions_up_to(DateTime.new(2011,10,1,1,0,1), DateTime.new(2010,4,1,1,0,0)))
|
361
|
-
assert_equal([t2,t3,t4,t5], dti.transitions_up_to(DateTime.new(2011,10,1,1,0,1), DateTime.new(2010,4,1,1,0,1)))
|
362
|
-
|
363
|
-
# Ruby 1.8.7 (built with GCC 8.3.0 on Ubuntu 19.04) fails to perform
|
364
|
-
# DateTime comparisons correctly when sub-seconds are used.
|
365
|
-
to = DateTime.new(2011,10,1,1,0,1)
|
366
|
-
from = DateTime.new(2010,4,1,1,0,Rational(DATETIME_RESOLUTION,1000000))
|
367
|
-
if to > from
|
368
|
-
assert_equal([t2,t3,t4,t5], dti.transitions_up_to(to, from))
|
369
|
-
else
|
370
|
-
puts "This platform does not consider the DateTime #{to.strftime('%Y-%m-%d %H:%m:%S.%N')} to be later than the DateTime #{from.strftime('%Y-%m-%d %H:%m:%S.%N')}"
|
371
|
-
end
|
372
|
-
|
373
|
-
assert_equal([t5], dti.transitions_up_to(DateTime.new(2015,1,1,0,0,0), DateTime.new(2011,10,1,1,0,0)))
|
374
|
-
assert_equal([], dti.transitions_up_to(DateTime.new(2015,1,1,0,0,0), DateTime.new(2011,10,1,1,0,1)))
|
375
|
-
end
|
376
|
-
|
377
|
-
def test_transitions_up_to_no_transitions
|
378
|
-
dti = TransitionDataTimezoneInfo.new('Test/Zone')
|
379
|
-
dti.offset :o1, -17900, 0, :TESTLMT
|
380
|
-
|
381
|
-
assert_equal([], dti.transitions_up_to(Time.utc(2015,1,1,0,0,0)))
|
382
|
-
assert_equal([], dti.transitions_up_to(Time.utc(2015,1,1,0,0,0).to_i))
|
383
|
-
assert_equal([], dti.transitions_up_to(DateTime.new(2015,1,1,0,0,0)))
|
384
|
-
end
|
385
|
-
|
386
|
-
def test_transitions_up_to_utc_to_not_greater_than_utc_from
|
387
|
-
dti = TransitionDataTimezoneInfo.new('Test/Zone')
|
388
|
-
dti.offset :o1, -17900, 0, :TESTLMT
|
389
|
-
|
390
|
-
assert_raises(ArgumentError) do
|
391
|
-
dti.transitions_up_to(Time.utc(2012,8,1,0,0,0), Time.utc(2013,8,1,0,0,0))
|
392
|
-
end
|
393
|
-
|
394
|
-
assert_raises(ArgumentError) do
|
395
|
-
dti.transitions_up_to(Time.utc(2012,8,1,0,0,0).to_i, Time.utc(2012,8,1,0,0,0).to_i)
|
396
|
-
end
|
397
|
-
|
398
|
-
assert_raises(ArgumentError) do
|
399
|
-
dti.transitions_up_to(DateTime.new(2012,8,1,0,0,0), DateTime.new(2012,8,1,0,0,0))
|
400
|
-
end
|
401
|
-
end
|
402
|
-
|
403
|
-
def test_datetime_and_timestamp_use
|
404
|
-
dti = TransitionDataTimezoneInfo.new('Test/Zone')
|
405
|
-
dti.offset :o1, 0, 0, :TESTS
|
406
|
-
dti.offset :o2, 0, 3600, :TESTD
|
407
|
-
|
408
|
-
dti.transition 1901, 12, :o2, -2147483649, 69573092117, 28800
|
409
|
-
dti.transition 1969, 12, :o1, -1, 210866759999, 86400
|
410
|
-
dti.transition 2001, 9, :o2, 1000000000, 529666909, 216
|
411
|
-
dti.transition 2038, 1, :o1, 2147483648, 3328347557, 1350
|
412
|
-
|
413
|
-
if RubyCoreSupport.time_supports_negative && RubyCoreSupport.time_supports_64bit
|
414
|
-
assert(dti.period_for_utc(DateTime.new(1901,12,13,20,45,51)).start_transition.at.eql?(TimeOrDateTime.new(-2147483649)))
|
415
|
-
else
|
416
|
-
assert(dti.period_for_utc(DateTime.new(1901,12,13,20,45,51)).start_transition.at.eql?(TimeOrDateTime.new(DateTime.new(1901,12,13,20,45,51))))
|
417
|
-
end
|
418
|
-
|
419
|
-
if RubyCoreSupport.time_supports_negative
|
420
|
-
assert(dti.period_for_utc(DateTime.new(1969,12,31,23,59,59)).start_transition.at.eql?(TimeOrDateTime.new(-1)))
|
421
|
-
else
|
422
|
-
assert(dti.period_for_utc(DateTime.new(1969,12,31,23,59,59)).start_transition.at.eql?(TimeOrDateTime.new(DateTime.new(1969,12,31,23,59,59))))
|
423
|
-
end
|
424
|
-
|
425
|
-
assert(dti.period_for_utc(DateTime.new(2001,9,9,2,46,40)).start_transition.at.eql?(TimeOrDateTime.new(1000000000)))
|
426
|
-
|
427
|
-
if RubyCoreSupport.time_supports_64bit
|
428
|
-
assert(dti.period_for_utc(DateTime.new(2038,1,19,3,14,8)).start_transition.at.eql?(TimeOrDateTime.new(2147483648)))
|
429
|
-
else
|
430
|
-
assert(dti.period_for_utc(DateTime.new(2038,1,19,3,14,8)).start_transition.at.eql?(TimeOrDateTime.new(DateTime.new(2038,1,19,3,14,8))))
|
431
|
-
end
|
432
|
-
end
|
433
|
-
end
|