tzinfo 1.2.4 → 1.2.7
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 +5 -5
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/CHANGES.md +75 -48
- data/LICENSE +1 -1
- data/README.md +9 -8
- data/lib/tzinfo/country_timezone.rb +14 -2
- data/lib/tzinfo/data_source.rb +1 -1
- data/lib/tzinfo/ruby_core_support.rb +24 -1
- data/lib/tzinfo/ruby_country_info.rb +6 -2
- data/lib/tzinfo/ruby_data_source.rb +24 -20
- data/lib/tzinfo/time_or_datetime.rb +12 -5
- data/lib/tzinfo/timezone.rb +10 -6
- data/lib/tzinfo/timezone_offset.rb +26 -3
- data/lib/tzinfo/timezone_period.rb +29 -5
- data/lib/tzinfo/timezone_proxy.rb +7 -1
- data/lib/tzinfo/timezone_transition.rb +12 -2
- data/lib/tzinfo/timezone_transition_definition.rb +6 -3
- data/lib/tzinfo/zoneinfo_country_info.rb +3 -1
- data/lib/tzinfo/zoneinfo_data_source.rb +8 -0
- data/lib/tzinfo/zoneinfo_timezone_info.rb +13 -7
- data/test/tc_country.rb +6 -4
- data/test/tc_country_timezone.rb +12 -0
- data/test/tc_ruby_country_info.rb +30 -0
- data/test/tc_ruby_data_source.rb +26 -2
- data/test/tc_time_or_datetime.rb +27 -6
- data/test/tc_timezone.rb +13 -2
- data/test/tc_timezone_period.rb +7 -0
- data/test/tc_timezone_proxy.rb +9 -0
- data/test/tc_timezone_transition.rb +14 -0
- data/test/tc_timezone_transition_definition.rb +11 -0
- data/test/tc_transition_data_timezone_info.rb +11 -1
- data/test/tc_zoneinfo_country_info.rb +14 -0
- data/test/tc_zoneinfo_data_source.rb +11 -2
- data/test/tc_zoneinfo_timezone_info.rb +108 -0
- data/test/test_utils.rb +63 -5
- data/test/ts_all_zoneinfo.rb +3 -1
- data/tzinfo.gemspec +2 -2
- metadata +22 -24
- metadata.gz.sig +0 -0
@@ -5,6 +5,10 @@ require 'tempfile'
|
|
5
5
|
|
6
6
|
include TZInfo
|
7
7
|
|
8
|
+
# Use send as a workaround for erroneous 'wrong number of arguments' errors with
|
9
|
+
# JRuby 9.0.5.0 when calling methods with Java implementations. See #114.
|
10
|
+
send(:using, RubyCoreSupport::UntaintExt) if RubyCoreSupport.const_defined?(:UntaintExt)
|
11
|
+
|
8
12
|
class TCZoneinfoTimezoneInfo < Minitest::Test
|
9
13
|
|
10
14
|
begin
|
@@ -1070,6 +1074,110 @@ class TCZoneinfoTimezoneInfo < Minitest::Test
|
|
1070
1074
|
assert_period(:XST1, 3600, 0, false, Time.utc(2000, 4, 1), nil, info)
|
1071
1075
|
end
|
1072
1076
|
end
|
1077
|
+
|
1078
|
+
def test_read_offset_negative_std_offset_dst
|
1079
|
+
# The zoneinfo files don't include the offset from standard time, so this
|
1080
|
+
# has to be derived by looking at changes in the total UTC offset.
|
1081
|
+
|
1082
|
+
offsets = [
|
1083
|
+
{:gmtoff => -100, :isdst => false, :abbrev => 'LMT'},
|
1084
|
+
{:gmtoff => 3600, :isdst => false, :abbrev => 'XST'},
|
1085
|
+
{:gmtoff => 0, :isdst => true, :abbrev => 'XWT'}]
|
1086
|
+
|
1087
|
+
transitions = [
|
1088
|
+
{:at => Time.utc(2000, 1, 1), :offset_index => 1},
|
1089
|
+
{:at => Time.utc(2000, 2, 1), :offset_index => 2},
|
1090
|
+
{:at => Time.utc(2000, 3, 1), :offset_index => 1},
|
1091
|
+
{:at => Time.utc(2000, 4, 1), :offset_index => 2},
|
1092
|
+
{:at => Time.utc(2000, 5, 1), :offset_index => 1}]
|
1093
|
+
|
1094
|
+
tzif_test(offsets, transitions) do |path, format|
|
1095
|
+
info = ZoneinfoTimezoneInfo.new('Zone/NegativeStdOffsetDst', path)
|
1096
|
+
assert_equal('Zone/NegativeStdOffsetDst', info.identifier)
|
1097
|
+
|
1098
|
+
assert_period(:LMT, -100, 0, false, nil, Time.utc(2000, 1, 1), info)
|
1099
|
+
assert_period(:XST, 3600, 0, false, Time.utc(2000, 1, 1), Time.utc(2000, 2, 1), info)
|
1100
|
+
assert_period(:XWT, 3600, -3600, true, Time.utc(2000, 2, 1), Time.utc(2000, 3, 1), info)
|
1101
|
+
assert_period(:XST, 3600, 0, false, Time.utc(2000, 3, 1), Time.utc(2000, 4, 1), info)
|
1102
|
+
assert_period(:XWT, 3600, -3600, true, Time.utc(2000, 4, 1), Time.utc(2000, 5, 1), info)
|
1103
|
+
assert_period(:XST, 3600, 0, false, Time.utc(2000, 5, 1), nil, info)
|
1104
|
+
end
|
1105
|
+
end
|
1106
|
+
|
1107
|
+
def test_read_offset_negative_std_offset_dst_initial_dst
|
1108
|
+
# The zoneinfo files don't include the offset from standard time, so this
|
1109
|
+
# has to be derived by looking at changes in the total UTC offset.
|
1110
|
+
|
1111
|
+
offsets = [
|
1112
|
+
{:gmtoff => -100, :isdst => false, :abbrev => 'LMT'},
|
1113
|
+
{:gmtoff => 0, :isdst => true, :abbrev => 'XWT'},
|
1114
|
+
{:gmtoff => 3600, :isdst => false, :abbrev => 'XST'}]
|
1115
|
+
|
1116
|
+
transitions = [
|
1117
|
+
{:at => Time.utc(2000, 1, 1), :offset_index => 1},
|
1118
|
+
{:at => Time.utc(2000, 2, 1), :offset_index => 2},
|
1119
|
+
{:at => Time.utc(2000, 3, 1), :offset_index => 1},
|
1120
|
+
{:at => Time.utc(2000, 4, 1), :offset_index => 2},
|
1121
|
+
{:at => Time.utc(2000, 5, 1), :offset_index => 1}]
|
1122
|
+
|
1123
|
+
tzif_test(offsets, transitions) do |path, format|
|
1124
|
+
info = ZoneinfoTimezoneInfo.new('Zone/NegativeStdOffsetDstInitialDst', path)
|
1125
|
+
assert_equal('Zone/NegativeStdOffsetDstInitialDst', info.identifier)
|
1126
|
+
|
1127
|
+
assert_period(:LMT, -100, 0, false, nil, Time.utc(2000, 1, 1), info)
|
1128
|
+
assert_period(:XWT, 3600, -3600, true, Time.utc(2000, 1, 1), Time.utc(2000, 2, 1), info)
|
1129
|
+
assert_period(:XST, 3600, 0, false, Time.utc(2000, 2, 1), Time.utc(2000, 3, 1), info)
|
1130
|
+
assert_period(:XWT, 3600, -3600, true, Time.utc(2000, 3, 1), Time.utc(2000, 4, 1), info)
|
1131
|
+
assert_period(:XST, 3600, 0, false, Time.utc(2000, 4, 1), Time.utc(2000, 5, 1), info)
|
1132
|
+
assert_period(:XWT, 3600, -3600, true, Time.utc(2000, 5, 1), nil, info)
|
1133
|
+
end
|
1134
|
+
end
|
1135
|
+
|
1136
|
+
def test_read_offset_prefer_base_offset_moves_to_dst_not_hour
|
1137
|
+
offsets = [
|
1138
|
+
{:gmtoff => -100, :isdst => false, :abbrev => 'LMT'},
|
1139
|
+
{:gmtoff => 0, :isdst => false, :abbrev => 'XST'},
|
1140
|
+
{:gmtoff => 1800, :isdst => true, :abbrev => 'XDT'},
|
1141
|
+
{:gmtoff => 1800, :isdst => false, :abbrev => 'XST'}]
|
1142
|
+
|
1143
|
+
transitions = [
|
1144
|
+
{:at => Time.utc(2000, 1, 1), :offset_index => 1},
|
1145
|
+
{:at => Time.utc(2000, 2, 1), :offset_index => 2},
|
1146
|
+
{:at => Time.utc(2000, 3, 1), :offset_index => 3}]
|
1147
|
+
|
1148
|
+
tzif_test(offsets, transitions) do |path, format|
|
1149
|
+
info = ZoneinfoTimezoneInfo.new('Zone/BaseOffsetMovesToDstNotHour', path)
|
1150
|
+
assert_equal('Zone/BaseOffsetMovesToDstNotHour', info.identifier)
|
1151
|
+
|
1152
|
+
assert_period(:LMT, -100, 0, false, nil, Time.utc(2000, 1, 1), info)
|
1153
|
+
assert_period(:XST, 0, 0, false, Time.utc(2000, 1, 1), Time.utc(2000, 2, 1), info)
|
1154
|
+
assert_period(:XDT, 0, 1800, true, Time.utc(2000, 2, 1), Time.utc(2000, 3, 1), info)
|
1155
|
+
assert_period(:XST, 1800, 0, false, Time.utc(2000, 3, 1), nil, info)
|
1156
|
+
end
|
1157
|
+
end
|
1158
|
+
|
1159
|
+
def test_read_offset_prefer_base_offset_moves_from_dst_not_hour
|
1160
|
+
offsets = [
|
1161
|
+
{:gmtoff => -100, :isdst => false, :abbrev => 'LMT'},
|
1162
|
+
{:gmtoff => 1800, :isdst => false, :abbrev => 'XST'},
|
1163
|
+
{:gmtoff => 1800, :isdst => true, :abbrev => 'XDT'},
|
1164
|
+
{:gmtoff => 0, :isdst => false, :abbrev => 'XST'}]
|
1165
|
+
|
1166
|
+
transitions = [
|
1167
|
+
{:at => Time.utc(2000, 1, 1), :offset_index => 1},
|
1168
|
+
{:at => Time.utc(2000, 2, 1), :offset_index => 2},
|
1169
|
+
{:at => Time.utc(2000, 3, 1), :offset_index => 3}]
|
1170
|
+
|
1171
|
+
tzif_test(offsets, transitions) do |path, format|
|
1172
|
+
info = ZoneinfoTimezoneInfo.new('Zone/BaseOffsetMovesFromDstNotHour', path)
|
1173
|
+
assert_equal('Zone/BaseOffsetMovesFromDstNotHour', info.identifier)
|
1174
|
+
|
1175
|
+
assert_period(:LMT, -100, 0, false, nil, Time.utc(2000, 1, 1), info)
|
1176
|
+
assert_period(:XST, 1800, 0, false, Time.utc(2000, 1, 1), Time.utc(2000, 2, 1), info)
|
1177
|
+
assert_period(:XDT, 0, 1800, true, Time.utc(2000, 2, 1), Time.utc(2000, 3, 1), info)
|
1178
|
+
assert_period(:XST, 0, 0, false, Time.utc(2000, 3, 1), nil, info)
|
1179
|
+
end
|
1180
|
+
end
|
1073
1181
|
|
1074
1182
|
def test_load_in_safe_mode
|
1075
1183
|
offsets = [{:gmtoff => -12094, :isdst => false, :abbrev => 'LT'}]
|
data/test/test_utils.rb
CHANGED
@@ -1,4 +1,6 @@
|
|
1
|
-
|
1
|
+
tests_dir = File.expand_path(File.dirname(__FILE__))
|
2
|
+
tests_dir.untaint if RUBY_VERSION < '2.7'
|
3
|
+
TESTS_DIR = tests_dir
|
2
4
|
TZINFO_LIB_DIR = File.expand_path(File.join(TESTS_DIR, '..', 'lib'))
|
3
5
|
TZINFO_TEST_DATA_DIR = File.join(TESTS_DIR, 'tzinfo-data')
|
4
6
|
TZINFO_TEST_ZONEINFO_DIR = File.join(TESTS_DIR, 'zoneinfo')
|
@@ -55,18 +57,57 @@ module Kernel
|
|
55
57
|
end
|
56
58
|
|
57
59
|
def safe_test(options = {})
|
58
|
-
# JRuby and Rubinus don't support SAFE levels.
|
59
|
-
available = !(defined?(RUBY_ENGINE) && %w(jruby rbx).include?(RUBY_ENGINE))
|
60
|
+
# Ruby >= 2.7, JRuby and Rubinus don't support SAFE levels.
|
61
|
+
available = RUBY_VERSION < '2.7' && !(defined?(RUBY_ENGINE) && %w(jruby rbx).include?(RUBY_ENGINE))
|
60
62
|
|
61
63
|
if available || options[:unavailable] != :skip
|
62
64
|
thread = Thread.new do
|
63
|
-
|
64
|
-
|
65
|
+
orig_diff = Minitest::Assertions.diff
|
66
|
+
|
67
|
+
if available
|
68
|
+
orig_safe = $SAFE
|
69
|
+
$SAFE = options[:level] || 1
|
70
|
+
end
|
71
|
+
begin
|
72
|
+
# Disable the use of external diff tools during safe mode tests (since
|
73
|
+
# safe mode will prevent their use). The initial value is retrieved
|
74
|
+
# before activating safe mode because the first time
|
75
|
+
# Minitest::Assertions.diff is called, it will attempt to find a diff
|
76
|
+
# tool. Finding the diff tool will also fail in safe mode.
|
77
|
+
Minitest::Assertions.diff = nil
|
78
|
+
begin
|
79
|
+
yield
|
80
|
+
ensure
|
81
|
+
Minitest::Assertions.diff = orig_diff
|
82
|
+
end
|
83
|
+
ensure
|
84
|
+
if available
|
85
|
+
# On Ruby < 2.6, setting $SAFE affects only the current thread
|
86
|
+
# and the $SAFE level cannot be downgraded. Catch and ignore the
|
87
|
+
# SecurityError.
|
88
|
+
# On Ruby >= 2.6, setting $SAFE is global, and the $SAFE level
|
89
|
+
# can be downgraded. Restore $SAFE back to the original level.
|
90
|
+
begin
|
91
|
+
$SAFE = orig_safe
|
92
|
+
rescue SecurityError
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
65
96
|
end
|
66
97
|
|
67
98
|
thread.join
|
68
99
|
end
|
69
100
|
end
|
101
|
+
|
102
|
+
def skip_if_has_bug_14060
|
103
|
+
# On Ruby 2.4.4 in safe mode, require will fail with a SecurityError for
|
104
|
+
# any file that has not previously been loaded, regardless of whether the
|
105
|
+
# file name is tainted.
|
106
|
+
# See https://bugs.ruby-lang.org/issues/14060#note-5.
|
107
|
+
if defined?(RUBY_ENGINE) && RUBY_ENGINE == 'ruby' && RUBY_VERSION == '2.4.4'
|
108
|
+
skip('Skipping test due to Ruby 2.4.4 being affected by Bug 14060 (see https://bugs.ruby-lang.org/issues/14060#note-5)')
|
109
|
+
end
|
110
|
+
end
|
70
111
|
|
71
112
|
def assert_array_same_items(expected, actual, msg = nil)
|
72
113
|
full_message = message(msg, '') { diff(expected, actual) }
|
@@ -75,6 +116,10 @@ module Kernel
|
|
75
116
|
end
|
76
117
|
|
77
118
|
def assert_sub_process_returns(expected_lines, code, extra_load_path = [], required = ['tzinfo'])
|
119
|
+
if defined?(RUBY_ENGINE) && RUBY_ENGINE == 'jruby' && JRUBY_VERSION.start_with?('9.0.') && RbConfig::CONFIG['host_os'] =~ /mswin/
|
120
|
+
skip('JRuby 9.0 on Windows cannot handle writing to the IO instance returned by popen')
|
121
|
+
end
|
122
|
+
|
78
123
|
ruby = File.join(RbConfig::CONFIG['bindir'],
|
79
124
|
RbConfig::CONFIG['ruby_install_name'] + RbConfig::CONFIG['EXEEXT'])
|
80
125
|
|
@@ -123,6 +168,19 @@ module Kernel
|
|
123
168
|
end
|
124
169
|
|
125
170
|
|
171
|
+
# Object#taint is a deprecated no-op in Ruby 2.7 and outputs a warning. It will
|
172
|
+
# be removed in 3.2. Silence the warning or supply a replacement.
|
173
|
+
if TZInfo::RubyCoreSupport.const_defined?(:UntaintExt)
|
174
|
+
module TaintExt
|
175
|
+
refine Object do
|
176
|
+
def taint
|
177
|
+
self
|
178
|
+
end
|
179
|
+
end
|
180
|
+
end
|
181
|
+
end
|
182
|
+
|
183
|
+
|
126
184
|
# JRuby 1.7.5 to 1.7.9 consider DateTime instances that differ by less than
|
127
185
|
# 1 millisecond to be equivalent (https://github.com/jruby/jruby/issues/1311).
|
128
186
|
#
|
data/test/ts_all_zoneinfo.rb
CHANGED
@@ -2,6 +2,8 @@ require File.join(File.expand_path(File.dirname(__FILE__)), 'test_utils.rb')
|
|
2
2
|
|
3
3
|
# Use a zoneinfo directory containing files needed by the tests.
|
4
4
|
# The symlinks in this directory are set up in test_utils.rb.
|
5
|
-
|
5
|
+
zoneinfo_path = File.join(File.expand_path(File.dirname(__FILE__)), 'zoneinfo')
|
6
|
+
zoneinfo_path.untaint if RUBY_VERSION < '2.7'
|
7
|
+
TZInfo::DataSource.set(:zoneinfo, zoneinfo_path)
|
6
8
|
|
7
9
|
require File.join(File.expand_path(File.dirname(__FILE__)), 'ts_all.rb')
|
data/tzinfo.gemspec
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'tzinfo'
|
3
|
-
s.version = '1.2.
|
3
|
+
s.version = '1.2.7'
|
4
4
|
s.summary = 'Daylight savings aware timezone library'
|
5
5
|
s.description = 'TZInfo provides daylight savings aware transformations between times in different time zones.'
|
6
6
|
s.author = 'Philip Ross'
|
7
7
|
s.email = 'phil.ross@gmail.com'
|
8
|
-
s.homepage = '
|
8
|
+
s.homepage = 'https://tzinfo.github.io'
|
9
9
|
s.license = 'MIT'
|
10
10
|
s.files = %w(CHANGES.md LICENSE Rakefile README.md tzinfo.gemspec .yardopts) +
|
11
11
|
Dir['lib/**/*.rb'].delete_if {|f| f.include?('.svn')} +
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tzinfo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Philip Ross
|
@@ -10,27 +10,26 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
VR0SBBcwFYETcGhpbC5yb3NzQGdtYWlsLmNvbTANBgkqhkiG9w0BAQsFAAOCAQEA
|
25
|
+
J80xgZ3gGdQVA8N+8NJANU5HLuZIU9jOaAlziU9ImoTgPiOHKGZC4as1TwT4kBt1
|
26
|
+
Qcnu7YSANYRrxP5tpOHsWPF/MQYgerAFCZS5+PzOTudwZ+7OsMW4/EMHy6aCVHEd
|
27
|
+
c7HzQRC4mSrDRpWxzyBnZ5nX5OAmIkKA8NgeKybT/4Ku6iFPPUQwlyxQaO+Wlxdo
|
28
|
+
FqHwpjRyoiVSpe4RUTNK3d3qesWPYi7Lxn6k6ZZeEdvG6ya33AXktE3jmmF+jPR1
|
29
|
+
J3Zn/kSTjTekiaspyGbczC3PUaeJNxr+yCvR4sk71Xmk/GaKKGOHedJ1uj/LAXrA
|
30
|
+
MR0mpl7b8zCg0PFC1J73uw==
|
32
31
|
-----END CERTIFICATE-----
|
33
|
-
date:
|
32
|
+
date: 2020-04-02 00:00:00.000000000 Z
|
34
33
|
dependencies:
|
35
34
|
- !ruby/object:Gem::Dependency
|
36
35
|
name: thread_safe
|
@@ -162,7 +161,7 @@ files:
|
|
162
161
|
- test/zoneinfo/zone.tab
|
163
162
|
- test/zoneinfo/zone1970.tab
|
164
163
|
- tzinfo.gemspec
|
165
|
-
homepage:
|
164
|
+
homepage: https://tzinfo.github.io
|
166
165
|
licenses:
|
167
166
|
- MIT
|
168
167
|
metadata: {}
|
@@ -185,8 +184,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
185
184
|
- !ruby/object:Gem::Version
|
186
185
|
version: '0'
|
187
186
|
requirements: []
|
188
|
-
|
189
|
-
rubygems_version: 2.6.14
|
187
|
+
rubygems_version: 3.1.2
|
190
188
|
signing_key:
|
191
189
|
specification_version: 4
|
192
190
|
summary: Daylight savings aware timezone library
|
metadata.gz.sig
CHANGED
Binary file
|