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.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/CHANGES.md +33 -0
- data/LICENSE +1 -1
- data/README.md +36 -31
- data/Rakefile +17 -23
- data/lib/tzinfo.rb +0 -22
- data/lib/tzinfo/country.rb +3 -22
- data/lib/tzinfo/country_index_definition.rb +0 -22
- data/lib/tzinfo/country_info.rb +0 -22
- data/lib/tzinfo/country_timezone.rb +46 -31
- data/lib/tzinfo/data_source.rb +7 -24
- data/lib/tzinfo/data_timezone.rb +7 -22
- data/lib/tzinfo/data_timezone_info.rb +0 -22
- data/lib/tzinfo/info_timezone.rb +0 -22
- data/lib/tzinfo/linked_timezone.rb +7 -22
- data/lib/tzinfo/linked_timezone_info.rb +0 -22
- data/lib/tzinfo/offset_rationals.rb +0 -22
- data/lib/tzinfo/ruby_core_support.rb +14 -22
- data/lib/tzinfo/ruby_country_info.rb +3 -25
- data/lib/tzinfo/ruby_data_source.rb +1 -23
- data/lib/tzinfo/time_or_datetime.rb +13 -27
- data/lib/tzinfo/timezone.rb +51 -23
- data/lib/tzinfo/timezone_definition.rb +0 -22
- data/lib/tzinfo/timezone_index_definition.rb +0 -22
- data/lib/tzinfo/timezone_info.rb +0 -22
- data/lib/tzinfo/timezone_offset.rb +0 -22
- data/lib/tzinfo/timezone_period.rb +1 -23
- data/lib/tzinfo/timezone_proxy.rb +6 -23
- data/lib/tzinfo/timezone_transition.rb +2 -24
- data/lib/tzinfo/timezone_transition_definition.rb +1 -23
- data/lib/tzinfo/transition_data_timezone_info.rb +0 -22
- data/lib/tzinfo/zoneinfo_country_info.rb +1 -23
- data/lib/tzinfo/zoneinfo_data_source.rb +177 -61
- data/lib/tzinfo/zoneinfo_timezone_info.rb +0 -22
- data/test/tc_country.rb +6 -24
- data/test/tc_country_index_definition.rb +1 -23
- data/test/tc_country_info.rb +1 -23
- data/test/tc_country_timezone.rb +82 -62
- data/test/tc_data_source.rb +22 -24
- data/test/tc_data_timezone.rb +12 -24
- data/test/tc_data_timezone_info.rb +1 -23
- data/test/tc_info_timezone.rb +1 -23
- data/test/tc_linked_timezone.rb +37 -24
- data/test/tc_linked_timezone_info.rb +1 -23
- data/test/tc_offset_rationals.rb +1 -23
- data/test/tc_ruby_core_support.rb +84 -33
- data/test/tc_ruby_country_info.rb +5 -27
- data/test/tc_ruby_data_source.rb +1 -23
- data/test/tc_time_or_datetime.rb +44 -36
- data/test/tc_timezone.rb +32 -48
- data/test/tc_timezone_definition.rb +1 -23
- data/test/tc_timezone_index_definition.rb +1 -23
- data/test/tc_timezone_info.rb +1 -23
- data/test/tc_timezone_london.rb +1 -23
- data/test/tc_timezone_melbourne.rb +1 -23
- data/test/tc_timezone_new_york.rb +1 -23
- data/test/tc_timezone_offset.rb +1 -23
- data/test/tc_timezone_period.rb +5 -27
- data/test/tc_timezone_proxy.rb +34 -28
- data/test/tc_timezone_transition.rb +1 -23
- data/test/tc_timezone_transition_definition.rb +1 -23
- data/test/tc_timezone_utc.rb +1 -23
- data/test/tc_transition_data_timezone_info.rb +3 -25
- data/test/tc_zoneinfo_country_info.rb +13 -35
- data/test/tc_zoneinfo_data_source.rb +358 -34
- data/test/tc_zoneinfo_timezone_info.rb +3 -27
- data/test/test_utils.rb +26 -30
- data/test/ts_all.rb +0 -22
- data/test/ts_all_ruby.rb +0 -22
- data/test/ts_all_zoneinfo.rb +0 -22
- data/test/tzinfo-data/tzinfo/data.rb +0 -22
- data/test/tzinfo-data/tzinfo/data/version.rb +0 -22
- data/tzinfo.gemspec +2 -2
- metadata +80 -80
- metadata.gz.sig +1 -3
data/test/tc_timezone.rb
CHANGED
@@ -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 TCTimezone < Test
|
5
|
+
class TCTimezone < Minitest::Test
|
28
6
|
|
29
7
|
class BlockCalled < StandardError
|
30
8
|
end
|
@@ -312,6 +290,8 @@ class TCTimezone < Test::Unit::TestCase
|
|
312
290
|
assert_raises(UnknownTimezone) { tz.now }
|
313
291
|
assert_raises(UnknownTimezone) { tz.current_period_and_time }
|
314
292
|
assert_raises(UnknownTimezone) { tz.transitions_up_to(DateTime.new(2006,1,1,1,0,0)) }
|
293
|
+
assert_raises(UnknownTimezone) { tz.canonical_identifier }
|
294
|
+
assert_raises(UnknownTimezone) { tz.canonical_zone }
|
315
295
|
end
|
316
296
|
|
317
297
|
def test_new_nil
|
@@ -327,6 +307,8 @@ class TCTimezone < Test::Unit::TestCase
|
|
327
307
|
assert_raises(UnknownTimezone) { tz.now }
|
328
308
|
assert_raises(UnknownTimezone) { tz.current_period_and_time }
|
329
309
|
assert_raises(UnknownTimezone) { tz.transitions_up_to(DateTime.new(2006,1,1,1,0,0)) }
|
310
|
+
assert_raises(UnknownTimezone) { tz.canonical_identifier }
|
311
|
+
assert_raises(UnknownTimezone) { tz.canonical_zone }
|
330
312
|
end
|
331
313
|
|
332
314
|
def test_new_arg
|
@@ -489,6 +471,7 @@ class TCTimezone < Test::Unit::TestCase
|
|
489
471
|
|
490
472
|
assert_equal(period, dt_period)
|
491
473
|
assert_equal(period, dt2_period)
|
474
|
+
assert_equal(period, dt3_period)
|
492
475
|
assert_equal(period, t_period)
|
493
476
|
assert_equal(period, t2_period)
|
494
477
|
assert_equal(period, t3_period)
|
@@ -535,16 +518,6 @@ class TCTimezone < Test::Unit::TestCase
|
|
535
518
|
end
|
536
519
|
|
537
520
|
def test_period_for_local_not_found
|
538
|
-
o1 = TimezoneOffset.new(-18000, 0, :EST)
|
539
|
-
o2 = TimezoneOffset.new(-18000, 3600, :EDT)
|
540
|
-
|
541
|
-
t1 = TestTimezoneTransition.new(o1, o2, 1067148000)
|
542
|
-
t2 = TestTimezoneTransition.new(o2, o1, 1081062000)
|
543
|
-
t3 = TestTimezoneTransition.new(o1, o2, 1099202400)
|
544
|
-
|
545
|
-
p1 = TimezonePeriod.new(t1, t2)
|
546
|
-
p2 = TimezonePeriod.new(t2, t3)
|
547
|
-
|
548
521
|
dt = DateTime.new(2004,4,4,2,0,0)
|
549
522
|
dt2 = DateTime.new(2004,4,4,2,0,Rational(987,1000))
|
550
523
|
t = Time.utc(2004,4,4,2,30,0)
|
@@ -849,6 +822,28 @@ class TCTimezone < Test::Unit::TestCase
|
|
849
822
|
assert(TestTimezone.new('Europe/London', nil, [period], tu2).local_to_utc(tu2).utc?)
|
850
823
|
end
|
851
824
|
|
825
|
+
def test_local_to_utc_utc_local_returns_utc
|
826
|
+
# Check that UTC time instances are always returned even if the system
|
827
|
+
# is using UTC as the time zone.
|
828
|
+
|
829
|
+
# Note that this will only test will only work correctly on platforms where
|
830
|
+
# setting the TZ environment variable has an effect. If setting TZ has no
|
831
|
+
# effect, then this test will still pass.
|
832
|
+
|
833
|
+
old_tz = ENV['TZ']
|
834
|
+
begin
|
835
|
+
ENV['TZ'] = 'UTC'
|
836
|
+
|
837
|
+
tz = Timezone.get('America/New_York')
|
838
|
+
|
839
|
+
t = tz.local_to_utc(Time.local(2014, 1, 11, 17, 18, 41))
|
840
|
+
assert_equal(Time.utc(2014, 1, 11, 22, 18, 41), t)
|
841
|
+
assert(t.utc?)
|
842
|
+
ensure
|
843
|
+
ENV['TZ'] = old_tz
|
844
|
+
end
|
845
|
+
end
|
846
|
+
|
852
847
|
def test_local_to_utc_invalid
|
853
848
|
dt = DateTime.new(2004,4,4,2,30,0)
|
854
849
|
tz = TestTimezone.new('America/New_York', nil, [], dt)
|
@@ -892,16 +887,6 @@ class TCTimezone < Test::Unit::TestCase
|
|
892
887
|
end
|
893
888
|
|
894
889
|
def test_local_to_utc_not_found
|
895
|
-
o1 = TimezoneOffset.new(-18000, 0, :EST)
|
896
|
-
o2 = TimezoneOffset.new(-18000, 3600, :EDT)
|
897
|
-
|
898
|
-
t1 = TestTimezoneTransition.new(o1, o2, 1067148000)
|
899
|
-
t2 = TestTimezoneTransition.new(o2, o1, 1081062000)
|
900
|
-
t3 = TestTimezoneTransition.new(o1, o2, 1099202400)
|
901
|
-
|
902
|
-
p1 = TimezonePeriod.new(t1, t2)
|
903
|
-
p2 = TimezonePeriod.new(t2, t3)
|
904
|
-
|
905
890
|
dt = DateTime.new(2004,4,4,2,0,0)
|
906
891
|
t = Time.utc(2004,4,4,2,30,0)
|
907
892
|
i = Time.utc(2004,4,4,2,59,59).to_i
|
@@ -1065,9 +1050,6 @@ class TCTimezone < Test::Unit::TestCase
|
|
1065
1050
|
dt = DateTime.new(2004,10,31,1,30,0)
|
1066
1051
|
tz = TestTimezone.new('America/New_York', nil, [p1, p2], dt)
|
1067
1052
|
|
1068
|
-
dt = DateTime.new(2004,10,31,1,30,0)
|
1069
|
-
tz = Timezone.get('America/New_York')
|
1070
|
-
|
1071
1053
|
assert_raises(AmbiguousTime) { tz.local_to_utc(dt) {|periods| nil} }
|
1072
1054
|
assert_raises(AmbiguousTime) { tz.local_to_utc(dt) {|periods| periods} }
|
1073
1055
|
assert_raises(AmbiguousTime) { tz.local_to_utc(dt) {|periods| []} }
|
@@ -1173,8 +1155,6 @@ class TCTimezone < Test::Unit::TestCase
|
|
1173
1155
|
end
|
1174
1156
|
|
1175
1157
|
def test_offsets_up_to_utc_to_not_greater_than_utc_from
|
1176
|
-
o = TimezoneOffset.new(600, 0, :LMT)
|
1177
|
-
|
1178
1158
|
assert_raises(ArgumentError) do
|
1179
1159
|
OffsetsUpToTestTimezone.new('Test/Zone', Time.utc(2012,8,1,0,0,0), Time.utc(2012,8,1,0,0,0), []).
|
1180
1160
|
offsets_up_to(Time.utc(2012,8,1,0,0,0), Time.utc(2012,8,1,0,0,0))
|
@@ -1222,6 +1202,10 @@ class TCTimezone < Test::Unit::TestCase
|
|
1222
1202
|
assert_equal(1, TestTimezone.new('Europe/Paris') <=> TestTimezone.new('America/New_York'))
|
1223
1203
|
end
|
1224
1204
|
|
1205
|
+
def test_compare_non_comparable
|
1206
|
+
assert_nil(TestTimezone.new('Europe/London') <=> Object.new)
|
1207
|
+
end
|
1208
|
+
|
1225
1209
|
def test_equality
|
1226
1210
|
assert_equal(true, TestTimezone.new('Europe/London') == TestTimezone.new('Europe/London'))
|
1227
1211
|
assert_equal(false, TestTimezone.new('Europe/London') == TestTimezone.new('Europe/london'))
|
@@ -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 TCTimezoneDefinition < Test
|
5
|
+
class TCTimezoneDefinition < Minitest::Test
|
28
6
|
|
29
7
|
module DataTest
|
30
8
|
include TimezoneDefinition
|
@@ -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 TCTimezoneIndexDefinition < Test
|
5
|
+
class TCTimezoneIndexDefinition < Minitest::Test
|
28
6
|
|
29
7
|
module TimezonesTest1
|
30
8
|
include TimezoneIndexDefinition
|
data/test/tc_timezone_info.rb
CHANGED
@@ -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 TCTimezoneInfo < Test
|
5
|
+
class TCTimezoneInfo < Minitest::Test
|
28
6
|
|
29
7
|
def test_identifier
|
30
8
|
ti = TimezoneInfo.new('Test/Zone')
|
data/test/tc_timezone_london.rb
CHANGED
@@ -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 TCTimezoneLondon < Test
|
5
|
+
class TCTimezoneLondon < Minitest::Test
|
28
6
|
def test_2004
|
29
7
|
#Europe/London Sun Mar 28 00:59:59 2004 UTC = Sun Mar 28 00:59:59 2004 GMT isdst=0 gmtoff=0
|
30
8
|
#Europe/London Sun Mar 28 01:00:00 2004 UTC = Sun Mar 28 02:00:00 2004 BST isdst=1 gmtoff=3600
|
@@ -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 TCTimezoneMelbourne < Test
|
5
|
+
class TCTimezoneMelbourne < Minitest::Test
|
28
6
|
def test_2004
|
29
7
|
#Australia/Melbourne Sat Mar 27 15:59:59 2004 UTC = Sun Mar 28 02:59:59 2004 EST isdst=1 gmtoff=39600
|
30
8
|
#Australia/Melbourne Sat Mar 27 16:00:00 2004 UTC = Sun Mar 28 02:00:00 2004 EST isdst=0 gmtoff=36000
|
@@ -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 TCTimezoneNewYork < Test
|
5
|
+
class TCTimezoneNewYork < Minitest::Test
|
28
6
|
def test_2004
|
29
7
|
#America/New_York Sun Apr 4 06:59:59 2004 UTC = Sun Apr 4 01:59:59 2004 EST isdst=0 gmtoff=-18000
|
30
8
|
#America/New_York Sun Apr 4 07:00:00 2004 UTC = Sun Apr 4 03:00:00 2004 EDT isdst=1 gmtoff=-14400
|
data/test/tc_timezone_offset.rb
CHANGED
@@ -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 TCTimezoneOffset < Test
|
5
|
+
class TCTimezoneOffset < Minitest::Test
|
28
6
|
|
29
7
|
def test_utc_offset
|
30
8
|
o1 = TimezoneOffset.new(18000, 0, :TEST)
|
data/test/tc_timezone_period.rb
CHANGED
@@ -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 TCTimezonePeriod < Test
|
5
|
+
class TCTimezonePeriod < Minitest::Test
|
28
6
|
|
29
7
|
class TestTimezoneTransition < TimezoneTransition
|
30
8
|
def initialize(offset, previous_offset, at)
|
@@ -558,13 +536,13 @@ class TCTimezonePeriod < Test::Unit::TestCase
|
|
558
536
|
t4 = TestTimezoneTransition.new(o1, o2, 1149541200)
|
559
537
|
|
560
538
|
p1 = TimezonePeriod.new(t1, t3)
|
561
|
-
p2 = TimezonePeriod.new(
|
562
|
-
p3 = TimezonePeriod.new(nil,
|
539
|
+
p2 = TimezonePeriod.new(t2, nil)
|
540
|
+
p3 = TimezonePeriod.new(nil, t4)
|
563
541
|
p4 = TimezonePeriod.new(nil, nil, o1)
|
564
542
|
|
565
543
|
assert_equal(t1.hash ^ t3.hash, p1.hash)
|
566
|
-
assert_equal(
|
567
|
-
assert_equal(nil.hash ^
|
544
|
+
assert_equal(t2.hash ^ nil.hash, p2.hash)
|
545
|
+
assert_equal(nil.hash ^ t4.hash, p3.hash)
|
568
546
|
assert_equal(nil.hash ^ nil.hash ^ o1.hash, p4.hash)
|
569
547
|
end
|
570
548
|
end
|
data/test/tc_timezone_proxy.rb
CHANGED
@@ -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 TCTimezoneProxy < Test
|
5
|
+
class TCTimezoneProxy < Minitest::Test
|
28
6
|
def test_not_exist
|
29
7
|
proxy = TimezoneProxy.new('Nothing/Special')
|
30
8
|
assert_equal('Nothing/Special', proxy.identifier)
|
@@ -36,17 +14,18 @@ class TCTimezoneProxy < Test::Unit::TestCase
|
|
36
14
|
assert_raises(InvalidTimezoneIdentifier) { proxy.local_to_utc(DateTime.new(2006,1,1,0,0,0)) }
|
37
15
|
assert_raises(InvalidTimezoneIdentifier) { proxy.period_for_utc(DateTime.new(2006,1,1,0,0,0)) }
|
38
16
|
assert_raises(InvalidTimezoneIdentifier) { proxy.period_for_local(DateTime.new(2006,1,1,0,0,0)) }
|
17
|
+
assert_raises(InvalidTimezoneIdentifier) { proxy.canonical_identifier }
|
18
|
+
assert_raises(InvalidTimezoneIdentifier) { proxy.canonical_zone }
|
39
19
|
end
|
40
20
|
|
41
21
|
def test_valid
|
42
22
|
proxy = TimezoneProxy.new('Europe/London')
|
43
23
|
assert_equal('Europe/London', proxy.identifier)
|
44
24
|
|
45
|
-
|
46
|
-
proxy.
|
47
|
-
proxy.
|
48
|
-
proxy.
|
49
|
-
proxy.current_time_and_period
|
25
|
+
assert_nothing_raised { proxy.now }
|
26
|
+
assert_nothing_raised { proxy.current_period }
|
27
|
+
assert_nothing_raised { proxy.current_period_and_time }
|
28
|
+
assert_nothing_raised { proxy.current_time_and_period }
|
50
29
|
|
51
30
|
real = Timezone.get('Europe/London')
|
52
31
|
|
@@ -60,6 +39,8 @@ class TCTimezoneProxy < Test::Unit::TestCase
|
|
60
39
|
assert_equal(real.friendly_identifier(true), proxy.friendly_identifier(true))
|
61
40
|
assert_equal(real.friendly_identifier(false), proxy.friendly_identifier(false))
|
62
41
|
assert_equal(real.friendly_identifier, proxy.friendly_identifier)
|
42
|
+
assert_equal(real.canonical_identifier, proxy.canonical_identifier)
|
43
|
+
assert_same(real.canonical_zone, proxy.canonical_zone)
|
63
44
|
|
64
45
|
assert_equal('Europe/London', proxy.identifier)
|
65
46
|
|
@@ -69,6 +50,31 @@ class TCTimezoneProxy < Test::Unit::TestCase
|
|
69
50
|
assert_equal(0, proxy <=> real)
|
70
51
|
end
|
71
52
|
|
53
|
+
def test_canonical_linked
|
54
|
+
# Test that the implementation of canonical_zone and canonical_identifier
|
55
|
+
# are actually calling the real timezone and not just returning it and
|
56
|
+
# its identifier.
|
57
|
+
|
58
|
+
real = Timezone.get('UTC')
|
59
|
+
proxy = TimezoneProxy.new('UTC')
|
60
|
+
|
61
|
+
# ZoneinfoDataSource doesn't return LinkedTimezoneInfo instances for any
|
62
|
+
# timezone.
|
63
|
+
if real.kind_of?(LinkedTimezone)
|
64
|
+
assert_equal('Etc/UTC', proxy.canonical_identifier)
|
65
|
+
assert_same(Timezone.get('Etc/UTC'), proxy.canonical_zone)
|
66
|
+
else
|
67
|
+
if DataSource.get.kind_of?(RubyDataSource)
|
68
|
+
# Not got a LinkedTimezone despite using a DataSource that supports it.
|
69
|
+
# Raise an exception as this shouldn't happen.
|
70
|
+
raise 'Non-LinkedTimezone instance returned for UTC using RubyDataSource'
|
71
|
+
end
|
72
|
+
|
73
|
+
assert_equal('UTC', proxy.canonical_identifier)
|
74
|
+
assert_same(Timezone.get('UTC'), proxy.canonical_zone)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
72
78
|
def test_equals
|
73
79
|
assert_equal(true, TimezoneProxy.new('Europe/London') == TimezoneProxy.new('Europe/London'))
|
74
80
|
assert_equal(false, TimezoneProxy.new('Europe/London') == TimezoneProxy.new('Europe/Paris'))
|