tzinfo 1.2.5 → 1.2.6
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 +2 -3
- data.tar.gz.sig +0 -0
- data/CHANGES.md +11 -0
- data/LICENSE +1 -1
- data/README.md +3 -2
- data/lib/tzinfo/ruby_core_support.rb +31 -1
- data/lib/tzinfo/ruby_data_source.rb +22 -20
- data/lib/tzinfo/timezone.rb +8 -4
- data/lib/tzinfo/zoneinfo_data_source.rb +8 -0
- data/lib/tzinfo/zoneinfo_timezone_info.rb +2 -0
- data/test/tc_country.rb +4 -2
- data/test/tc_ruby_data_source.rb +24 -2
- data/test/tc_time_or_datetime.rb +12 -6
- data/test/tc_timezone.rb +11 -2
- data/test/tc_transition_data_timezone_info.rb +11 -1
- data/test/tc_zoneinfo_data_source.rb +11 -2
- data/test/tc_zoneinfo_timezone_info.rb +2 -0
- data/test/test_utils.rb +28 -3
- data/test/ts_all_zoneinfo.rb +3 -1
- data/tzinfo.gemspec +1 -1
- metadata +21 -23
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c204b46efe2fc4448fbb719bc143c031e71e5a5eaa21593cee6b04a8904b21f6
|
4
|
+
data.tar.gz: a70e08a0cb1ed9439ca48899e068e0455d2bf123601ef19db308cd9a39e156ba
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 15ec7aefd75724e350d8f287d2b9af340af7e5916f6e535dd1d6673bbdeae2615992dd5b33181a354b400bce39fb054fd691d41453b335f5a527847eecfaf2b4
|
7
|
+
data.tar.gz: 6766a63a1a690944ef8ea3ac1ed9d5018216d1f139a1bbcddf99f00fa293bf56779b71bf2e27c80e0d4bf01cdcba375b3f6b5d046470324713a43e0747e0a9dd
|
checksums.yaml.gz.sig
CHANGED
@@ -1,3 +1,2 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
�Ck=�t�1�X�{L���z���@�K�;v�Mz�s�n=/m�I�ZF��;ݍƁu*�-6�Rքt��G�KV�?����C
|
1
|
+
���Ш{���!1��Q���p� ����R|�C wN�#�|Q�/T�.�4�i�h���a�f�O�@�GhF}�]ֱ�YL@܅��OGu%6h�k�1,gᔈ�^J�VR�h��?T���5��Cj������Md���_�zI�o0}�π�-��
|
2
|
+
�D~Km�~L�5٥_.����|�˪o%\�TВ��=�ҹ�����l�3 ƴ��X]6��y��R��DX�4�7i�VMfv�H��ݦ[L��7O�m{Be��m
|
data.tar.gz.sig
CHANGED
Binary file
|
data/CHANGES.md
CHANGED
@@ -1,3 +1,14 @@
|
|
1
|
+
Version 1.2.6 - 24-Dec-2019
|
2
|
+
---------------------------
|
3
|
+
|
4
|
+
* Timezone#strftime('%s', time) will now return the correct number of seconds
|
5
|
+
since the epoch. #91.
|
6
|
+
* Removed the unused TZInfo::RubyDataSource::REQUIRE_PATH constant.
|
7
|
+
* Fixed "SecurityError: Insecure operation - require" exceptions when loading
|
8
|
+
data with recent Ruby releases in safe mode.
|
9
|
+
* Fixed warnings when running on Ruby 2.7. #106 and #111.
|
10
|
+
|
11
|
+
|
1
12
|
Version 1.2.5 - 4-Feb-2018
|
2
13
|
--------------------------
|
3
14
|
|
data/LICENSE
CHANGED
data/README.md
CHANGED
@@ -60,8 +60,9 @@ of `TZInfo::Timezone`) and convert a time in UTC to local New York time:
|
|
60
60
|
local = tz.utc_to_local(Time.utc(2005,8,29,15,35,0))
|
61
61
|
|
62
62
|
Note that the local Time returned will have a UTC timezone (`local.zone` will
|
63
|
-
return `"UTC"`). This is because the
|
64
|
-
UTC and the
|
63
|
+
return `"UTC"`). This is because the Time class in older (but still supported by
|
64
|
+
TZInfo) versions of Ruby can only handle two timezones: UTC and the system local
|
65
|
+
timezone.
|
65
66
|
|
66
67
|
To convert from a local time to UTC, the `local_to_utc` method can be used as
|
67
68
|
follows:
|
@@ -137,10 +137,40 @@ module TZInfo
|
|
137
137
|
def self.open_file(file_name, mode, opts, &block)
|
138
138
|
File.open(file_name, mode, &block)
|
139
139
|
end
|
140
|
-
|
140
|
+
elsif RUBY_VERSION =~ /\A1\.9\./
|
141
141
|
def self.open_file(file_name, mode, opts, &block)
|
142
142
|
File.open(file_name, mode, opts, &block)
|
143
143
|
end
|
144
|
+
else
|
145
|
+
# Evaluate method as a string because **opts isn't valid syntax prior to
|
146
|
+
# Ruby 2.0.
|
147
|
+
eval(<<-EOF
|
148
|
+
def self.open_file(file_name, mode, opts, &block)
|
149
|
+
File.open(file_name, mode, **opts, &block)
|
150
|
+
end
|
151
|
+
EOF
|
152
|
+
)
|
153
|
+
end
|
154
|
+
|
155
|
+
|
156
|
+
# Object#untaint is a deprecated no-op in Ruby >= 2.7 and will be removed in
|
157
|
+
# 3.0. Add a refinement to either silence the warning, or supply the method
|
158
|
+
# if needed.
|
159
|
+
old_verbose = $VERBOSE
|
160
|
+
$VERBOSE = false
|
161
|
+
begin
|
162
|
+
o = Object.new
|
163
|
+
if [:taint, :untaint, :tainted?].none? {|m| o.respond_to?(m) } || !o.taint.tainted?
|
164
|
+
module UntaintExt
|
165
|
+
refine Object do
|
166
|
+
def untaint
|
167
|
+
self
|
168
|
+
end
|
169
|
+
end
|
170
|
+
end
|
171
|
+
end
|
172
|
+
ensure
|
173
|
+
$VERBOSE = old_verbose
|
144
174
|
end
|
145
175
|
end
|
146
176
|
end
|
@@ -1,4 +1,6 @@
|
|
1
1
|
module TZInfo
|
2
|
+
using RubyCoreSupport::UntaintExt if RubyCoreSupport.const_defined?(:UntaintExt)
|
3
|
+
|
2
4
|
# A DataSource that loads data from the set of Ruby modules included in the
|
3
5
|
# TZInfo::Data library (tzinfo-data gem).
|
4
6
|
#
|
@@ -6,15 +8,30 @@ module TZInfo
|
|
6
8
|
#
|
7
9
|
# TZInfo::DataSource.set(:ruby)
|
8
10
|
class RubyDataSource < DataSource
|
9
|
-
# Base path for require.
|
10
|
-
REQUIRE_PATH = File.join('tzinfo', 'data', 'definitions')
|
11
|
-
|
12
11
|
# Whether the timezone index has been loaded yet.
|
13
12
|
@@timezone_index_loaded = false
|
14
13
|
|
15
14
|
# Whether the country index has been loaded yet.
|
16
15
|
@@country_index_loaded = false
|
17
16
|
|
17
|
+
# Initializes a new RubyDataSource instance.
|
18
|
+
def initialize
|
19
|
+
tzinfo_data = File.join('tzinfo', 'data')
|
20
|
+
begin
|
21
|
+
require(tzinfo_data)
|
22
|
+
|
23
|
+
data_file = File.join('', 'tzinfo', 'data.rb')
|
24
|
+
path = $".reverse_each.detect {|p| p.end_with?(data_file) }
|
25
|
+
if path
|
26
|
+
@base_path = File.join(File.dirname(path), 'data').untaint
|
27
|
+
else
|
28
|
+
@base_path = tzinfo_data
|
29
|
+
end
|
30
|
+
rescue LoadError
|
31
|
+
@base_path = tzinfo_data
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
18
35
|
# Returns a TimezoneInfo instance for a given identifier.
|
19
36
|
# Raises InvalidTimezoneIdentifier if the timezone is not found or the
|
20
37
|
# identifier is invalid.
|
@@ -93,27 +110,17 @@ module TZInfo
|
|
93
110
|
end
|
94
111
|
|
95
112
|
# Requires an index by its name.
|
96
|
-
def
|
113
|
+
def require_index(name)
|
97
114
|
require_data(*['indexes', name])
|
98
115
|
end
|
99
116
|
|
100
117
|
# Requires a file from tzinfo/data.
|
101
118
|
def require_data(*file)
|
102
|
-
|
103
|
-
end
|
104
|
-
|
105
|
-
# Requires a file from tzinfo/data.
|
106
|
-
def self.require_data(*file)
|
107
|
-
require File.join('tzinfo', 'data', *file)
|
119
|
+
require(File.join(@base_path, *file))
|
108
120
|
end
|
109
121
|
|
110
122
|
# Loads in the index of timezones if it hasn't already been loaded.
|
111
123
|
def load_timezone_index
|
112
|
-
self.class.load_timezone_index
|
113
|
-
end
|
114
|
-
|
115
|
-
# Loads in the index of timezones if it hasn't already been loaded.
|
116
|
-
def self.load_timezone_index
|
117
124
|
unless @@timezone_index_loaded
|
118
125
|
require_index('timezones')
|
119
126
|
@@timezone_index_loaded = true
|
@@ -122,11 +129,6 @@ module TZInfo
|
|
122
129
|
|
123
130
|
# Loads in the index of countries if it hasn't already been loaded.
|
124
131
|
def load_country_index
|
125
|
-
self.class.load_country_index
|
126
|
-
end
|
127
|
-
|
128
|
-
# Loads in the index of countries if it hasn't already been loaded.
|
129
|
-
def self.load_country_index
|
130
132
|
unless @@country_index_loaded
|
131
133
|
require_index('countries')
|
132
134
|
@@country_index_loaded = true
|
data/lib/tzinfo/timezone.rb
CHANGED
@@ -571,17 +571,21 @@ module TZInfo
|
|
571
571
|
# version 2.0.0, %z will be passed to Time#strftime and DateTime#strftime
|
572
572
|
# instead. Some of the formatting options may cease to be available
|
573
573
|
# depending on the version of Ruby in use (for example, %:::z is only
|
574
|
-
# supported by Time#strftime from MRI version 2.0.0 onwards.
|
574
|
+
# supported by Time#strftime from MRI version 2.0.0 onwards).
|
575
575
|
def strftime(format, utc = Time.now.utc)
|
576
|
+
utc = TimeOrDateTime.wrap(utc)
|
576
577
|
period = period_for_utc(utc)
|
577
|
-
|
578
|
-
local =
|
578
|
+
local_wrapped = period.to_local(utc)
|
579
|
+
local = local_wrapped.to_orig
|
580
|
+
local = local_wrapped.to_time unless local.kind_of?(Time) || local.kind_of?(DateTime)
|
579
581
|
abbreviation = period.abbreviation.to_s.gsub(/%/, '%%')
|
580
582
|
|
581
|
-
format = format.gsub(/%(%*)(
|
583
|
+
format = format.gsub(/%(%*)([sZ]|:*z)/) do
|
582
584
|
if $1.length.odd?
|
583
585
|
# Escaped literal percent or series of percents. Pass on to strftime.
|
584
586
|
"#$1%#$2"
|
587
|
+
elsif $2 == "s"
|
588
|
+
"#$1#{utc.to_i}"
|
585
589
|
elsif $2 == "Z"
|
586
590
|
"#$1#{abbreviation}"
|
587
591
|
else
|
@@ -1,4 +1,12 @@
|
|
1
1
|
module TZInfo
|
2
|
+
# Use send as a workaround for an issue on JRuby 9.2.9.0 where using the
|
3
|
+
# refinement causes calls to RubyCoreSupport.file_open to fail to pass the
|
4
|
+
# block parameter.
|
5
|
+
#
|
6
|
+
# https://travis-ci.org/tzinfo/tzinfo/jobs/628812051#L1931
|
7
|
+
# https://github.com/jruby/jruby/issues/6009
|
8
|
+
send(:using, TZInfo::RubyCoreSupport::UntaintExt) if TZInfo::RubyCoreSupport.const_defined?(:UntaintExt)
|
9
|
+
|
2
10
|
# An InvalidZoneinfoDirectory exception is raised if the DataSource is
|
3
11
|
# set to a specific zoneinfo path, which is not a valid zoneinfo directory
|
4
12
|
# (i.e. a directory containing index files named iso3166.tab and zone.tab
|
data/test/tc_country.rb
CHANGED
@@ -2,6 +2,8 @@ require File.join(File.expand_path(File.dirname(__FILE__)), 'test_utils')
|
|
2
2
|
|
3
3
|
include TZInfo
|
4
4
|
|
5
|
+
using TaintExt if Module.const_defined?(:TaintExt)
|
6
|
+
|
5
7
|
class TCCountry < Minitest::Test
|
6
8
|
def setup
|
7
9
|
@orig_data_source = DataSource.get
|
@@ -46,7 +48,7 @@ class TCCountry < Minitest::Test
|
|
46
48
|
def test_get_tainted_loaded
|
47
49
|
Country.get('GB')
|
48
50
|
|
49
|
-
safe_test do
|
51
|
+
safe_test(:unavailable => :skip) do
|
50
52
|
code = 'GB'.dup.taint
|
51
53
|
assert(code.tainted?)
|
52
54
|
country = Country.get(code)
|
@@ -65,7 +67,7 @@ class TCCountry < Minitest::Test
|
|
65
67
|
end
|
66
68
|
|
67
69
|
def test_get_tainted_not_previously_loaded
|
68
|
-
safe_test do
|
70
|
+
safe_test(:unavailable => :skip) do
|
69
71
|
code = 'GB'.dup.taint
|
70
72
|
assert(code.tainted?)
|
71
73
|
country = Country.get(code)
|
data/test/tc_ruby_data_source.rb
CHANGED
@@ -2,11 +2,29 @@ require File.join(File.expand_path(File.dirname(__FILE__)), 'test_utils')
|
|
2
2
|
|
3
3
|
include TZInfo
|
4
4
|
|
5
|
+
using TaintExt if Module.const_defined?(:TaintExt)
|
6
|
+
|
5
7
|
class TCRubyDataSource < Minitest::Test
|
6
8
|
def setup
|
7
9
|
@data_source = RubyDataSource.new
|
8
10
|
end
|
9
11
|
|
12
|
+
def test_initialize_not_found
|
13
|
+
# A failure to load tzinfo/data in initialize will not cause an exception.
|
14
|
+
# Attempts to load data files will subsequently fail.
|
15
|
+
code = <<-EOF
|
16
|
+
begin
|
17
|
+
ds = TZInfo::RubyDataSource.new
|
18
|
+
puts 'Initialized'
|
19
|
+
ds.load_timezone_info('Europe/London')
|
20
|
+
rescue Exception => e
|
21
|
+
puts e.class
|
22
|
+
end
|
23
|
+
EOF
|
24
|
+
|
25
|
+
assert_sub_process_returns(['Initialized', 'TZInfo::InvalidTimezoneIdentifier'], code)
|
26
|
+
end
|
27
|
+
|
10
28
|
def test_load_timezone_info_data
|
11
29
|
info = @data_source.load_timezone_info('Europe/London')
|
12
30
|
assert_kind_of(DataTimezoneInfo, info)
|
@@ -55,7 +73,9 @@ class TCRubyDataSource < Minitest::Test
|
|
55
73
|
end
|
56
74
|
|
57
75
|
def test_load_timezone_info_tainted
|
58
|
-
|
76
|
+
skip_if_has_bug_14060
|
77
|
+
|
78
|
+
safe_test(:unavailable => :skip) do
|
59
79
|
identifier = 'Europe/Amsterdam'.dup.taint
|
60
80
|
assert(identifier.tainted?)
|
61
81
|
info = @data_source.load_timezone_info(identifier)
|
@@ -65,6 +85,8 @@ class TCRubyDataSource < Minitest::Test
|
|
65
85
|
end
|
66
86
|
|
67
87
|
def test_load_timezone_info_tainted_and_frozen
|
88
|
+
skip_if_has_bug_14060
|
89
|
+
|
68
90
|
safe_test do
|
69
91
|
info = @data_source.load_timezone_info('Europe/Amsterdam'.dup.taint.freeze)
|
70
92
|
assert_equal('Europe/Amsterdam', info.identifier)
|
@@ -119,7 +141,7 @@ class TCRubyDataSource < Minitest::Test
|
|
119
141
|
end
|
120
142
|
|
121
143
|
def test_load_country_info_tainted
|
122
|
-
safe_test do
|
144
|
+
safe_test(:unavailable => :skip) do
|
123
145
|
code = 'NL'.dup.taint
|
124
146
|
assert(code.tainted?)
|
125
147
|
info = @data_source.load_country_info(code)
|
data/test/tc_time_or_datetime.rb
CHANGED
@@ -4,6 +4,12 @@ require 'rational' unless defined?(Rational)
|
|
4
4
|
include TZInfo
|
5
5
|
|
6
6
|
class TCTimeOrDateTime < Minitest::Test
|
7
|
+
# Ruby 1.8.7 (built with GCC 8.3.0 on Ubuntu 19.04) fails to perform DateTime
|
8
|
+
# arithmetic operations correctly when sub-seconds are used. Detect this and
|
9
|
+
# disable the affected tests.
|
10
|
+
DATETIME_SUBSECOND_ARITHMETIC_IS_BROKEN = (DateTime.new(2019, 12, 22, 15, 0, Rational(1, 1000)) + Rational(1, 86400)).strftime('%Q') != '1577026801001'
|
11
|
+
puts "DateTime sub-second arithmetic is broken on this platform" if DATETIME_SUBSECOND_ARITHMETIC_IS_BROKEN
|
12
|
+
|
7
13
|
def test_initialize_time
|
8
14
|
assert_nothing_raised do
|
9
15
|
TimeOrDateTime.new(Time.utc(2006, 3, 24, 15, 32, 3, 721000))
|
@@ -500,12 +506,12 @@ class TCTimeOrDateTime < Minitest::Test
|
|
500
506
|
assert_equal(Time.utc(2006, 3, 24, 15, 32, 4), (TimeOrDateTime.new(Time.utc(2006, 3, 24, 15, 32, 3)) + 1).to_orig)
|
501
507
|
assert_equal(Time.utc(2006, 3, 24, 15, 32, 4, 721000), (TimeOrDateTime.new(Time.utc(2006, 3, 24, 15, 32, 3, 721000)) + 1).to_orig)
|
502
508
|
assert_equal(DateTime.new(2006, 3, 24, 15, 32, 4), (TimeOrDateTime.new(DateTime.new(2006, 3, 24, 15, 32, 3)) + 1).to_orig)
|
503
|
-
assert_equal(DateTime.new(2006, 3, 24, 15, 32, 4 + Rational(721, 1000)), (TimeOrDateTime.new(DateTime.new(2006, 3, 24, 15, 32, 3 + Rational(721, 1000))) + 1).to_orig)
|
509
|
+
assert_equal(DateTime.new(2006, 3, 24, 15, 32, 4 + Rational(721, 1000)), (TimeOrDateTime.new(DateTime.new(2006, 3, 24, 15, 32, 3 + Rational(721, 1000))) + 1).to_orig) unless DATETIME_SUBSECOND_ARITHMETIC_IS_BROKEN
|
504
510
|
assert_equal(1143214324, (TimeOrDateTime.new(1143214323) + 1).to_orig)
|
505
511
|
assert_equal(Time.utc(2006, 3, 24, 15, 32, 2), (TimeOrDateTime.new(Time.utc(2006, 3, 24, 15, 32, 3)) + (-1)).to_orig)
|
506
512
|
assert_equal(Time.utc(2006, 3, 24, 15, 32, 2, 721000), (TimeOrDateTime.new(Time.utc(2006, 3, 24, 15, 32, 3, 721000)) + (-1)).to_orig)
|
507
513
|
assert_equal(DateTime.new(2006, 3, 24, 15, 32, 2), (TimeOrDateTime.new(DateTime.new(2006, 3, 24, 15, 32, 3)) + (-1)).to_orig)
|
508
|
-
assert_equal(DateTime.new(2006, 3, 24, 15, 32, 2 + Rational(721, 1000)), (TimeOrDateTime.new(DateTime.new(2006, 3, 24, 15, 32, 3 + Rational(721, 1000))) + (-1)).to_orig)
|
514
|
+
assert_equal(DateTime.new(2006, 3, 24, 15, 32, 2 + Rational(721, 1000)), (TimeOrDateTime.new(DateTime.new(2006, 3, 24, 15, 32, 3 + Rational(721, 1000))) + (-1)).to_orig) unless DATETIME_SUBSECOND_ARITHMETIC_IS_BROKEN
|
509
515
|
assert_equal(1143214322, (TimeOrDateTime.new(1143214323) + (-1)).to_orig)
|
510
516
|
end
|
511
517
|
|
@@ -518,12 +524,12 @@ class TCTimeOrDateTime < Minitest::Test
|
|
518
524
|
assert_equal(Time.utc(2006, 3, 24, 15, 32, 2), (TimeOrDateTime.new(Time.utc(2006, 3, 24, 15, 32, 3)) - 1).to_orig)
|
519
525
|
assert_equal(Time.utc(2006, 3, 24, 15, 32, 2, 721000), (TimeOrDateTime.new(Time.utc(2006, 3, 24, 15, 32, 3, 721000)) - 1).to_orig)
|
520
526
|
assert_equal(DateTime.new(2006, 3, 24, 15, 32, 2), (TimeOrDateTime.new(DateTime.new(2006, 3, 24, 15, 32, 3)) - 1).to_orig)
|
521
|
-
assert_equal(DateTime.new(2006, 3, 24, 15, 32, 2 + Rational(721, 1000)), (TimeOrDateTime.new(DateTime.new(2006, 3, 24, 15, 32, 3 + Rational(721, 1000))) - 1).to_orig)
|
527
|
+
assert_equal(DateTime.new(2006, 3, 24, 15, 32, 2 + Rational(721, 1000)), (TimeOrDateTime.new(DateTime.new(2006, 3, 24, 15, 32, 3 + Rational(721, 1000))) - 1).to_orig) unless DATETIME_SUBSECOND_ARITHMETIC_IS_BROKEN
|
522
528
|
assert_equal(1143214322, (TimeOrDateTime.new(1143214323) - 1).to_orig)
|
523
529
|
assert_equal(Time.utc(2006, 3, 24, 15, 32, 4), (TimeOrDateTime.new(Time.utc(2006, 3, 24, 15, 32, 3)) - (-1)).to_orig)
|
524
530
|
assert_equal(Time.utc(2006, 3, 24, 15, 32, 4, 721000), (TimeOrDateTime.new(Time.utc(2006, 3, 24, 15, 32, 3, 721000)) - (-1)).to_orig)
|
525
531
|
assert_equal(DateTime.new(2006, 3, 24, 15, 32, 4), (TimeOrDateTime.new(DateTime.new(2006, 3, 24, 15, 32, 3)) - (-1)).to_orig)
|
526
|
-
assert_equal(DateTime.new(2006, 3, 24, 15, 32, 4 + Rational(721, 1000)), (TimeOrDateTime.new(DateTime.new(2006, 3, 24, 15, 32, 3 + Rational(721, 1000))) - (-1)).to_orig)
|
532
|
+
assert_equal(DateTime.new(2006, 3, 24, 15, 32, 4 + Rational(721, 1000)), (TimeOrDateTime.new(DateTime.new(2006, 3, 24, 15, 32, 3 + Rational(721, 1000))) - (-1)).to_orig) unless DATETIME_SUBSECOND_ARITHMETIC_IS_BROKEN
|
527
533
|
assert_equal(1143214324, (TimeOrDateTime.new(1143214323) - (-1)).to_orig)
|
528
534
|
end
|
529
535
|
|
@@ -536,12 +542,12 @@ class TCTimeOrDateTime < Minitest::Test
|
|
536
542
|
assert_equal(Time.utc(2006, 3, 24, 15, 32, 4), TimeOrDateTime.new(Time.utc(2006, 3, 24, 15, 32, 3)).add_with_convert(1).to_orig)
|
537
543
|
assert_equal(Time.utc(2006, 3, 24, 15, 32, 4, 721000), TimeOrDateTime.new(Time.utc(2006, 3, 24, 15, 32, 3, 721000)).add_with_convert(1).to_orig)
|
538
544
|
assert_equal(DateTime.new(2006, 3, 24, 15, 32, 4), TimeOrDateTime.new(DateTime.new(2006, 3, 24, 15, 32, 3)).add_with_convert(1).to_orig)
|
539
|
-
assert_equal(DateTime.new(2006, 3, 24, 15, 32, 4 + Rational(721, 1000)), TimeOrDateTime.new(DateTime.new(2006, 3, 24, 15, 32, 3 + Rational(721, 1000))).add_with_convert(1).to_orig)
|
545
|
+
assert_equal(DateTime.new(2006, 3, 24, 15, 32, 4 + Rational(721, 1000)), TimeOrDateTime.new(DateTime.new(2006, 3, 24, 15, 32, 3 + Rational(721, 1000))).add_with_convert(1).to_orig) unless DATETIME_SUBSECOND_ARITHMETIC_IS_BROKEN
|
540
546
|
assert_equal(1143214324, TimeOrDateTime.new(1143214323).add_with_convert(1).to_orig)
|
541
547
|
assert_equal(Time.utc(2006, 3, 24, 15, 32, 2), TimeOrDateTime.new(Time.utc(2006, 3, 24, 15, 32, 3)).add_with_convert(-1).to_orig)
|
542
548
|
assert_equal(Time.utc(2006, 3, 24, 15, 32, 2, 721000), TimeOrDateTime.new(Time.utc(2006, 3, 24, 15, 32, 3, 721000)).add_with_convert(-1).to_orig)
|
543
549
|
assert_equal(DateTime.new(2006, 3, 24, 15, 32, 2), TimeOrDateTime.new(DateTime.new(2006, 3, 24, 15, 32, 3)).add_with_convert(-1).to_orig)
|
544
|
-
assert_equal(DateTime.new(2006, 3, 24, 15, 32, 2 + Rational(721, 1000)), TimeOrDateTime.new(DateTime.new(2006, 3, 24, 15, 32, 3 + Rational(721, 1000))).add_with_convert(-1).to_orig)
|
550
|
+
assert_equal(DateTime.new(2006, 3, 24, 15, 32, 2 + Rational(721, 1000)), TimeOrDateTime.new(DateTime.new(2006, 3, 24, 15, 32, 3 + Rational(721, 1000))).add_with_convert(-1).to_orig) unless DATETIME_SUBSECOND_ARITHMETIC_IS_BROKEN
|
545
551
|
assert_equal(1143214322, TimeOrDateTime.new(1143214323).add_with_convert(-1).to_orig)
|
546
552
|
|
547
553
|
if RubyCoreSupport.time_supports_negative
|
data/test/tc_timezone.rb
CHANGED
@@ -2,6 +2,8 @@ require File.join(File.expand_path(File.dirname(__FILE__)), 'test_utils')
|
|
2
2
|
|
3
3
|
include TZInfo
|
4
4
|
|
5
|
+
using TaintExt if Module.const_defined?(:TaintExt)
|
6
|
+
|
5
7
|
class TCTimezone < Minitest::Test
|
6
8
|
|
7
9
|
class BlockCalled < StandardError
|
@@ -242,7 +244,7 @@ class TCTimezone < Minitest::Test
|
|
242
244
|
def test_get_tainted_loaded
|
243
245
|
Timezone.get('Europe/Andorra')
|
244
246
|
|
245
|
-
safe_test do
|
247
|
+
safe_test(:unavailable => :skip) do
|
246
248
|
identifier = 'Europe/Andorra'.dup.taint
|
247
249
|
assert(identifier.tainted?)
|
248
250
|
tz = Timezone.get(identifier)
|
@@ -261,7 +263,9 @@ class TCTimezone < Minitest::Test
|
|
261
263
|
end
|
262
264
|
|
263
265
|
def test_get_tainted_not_previously_loaded
|
264
|
-
|
266
|
+
skip_if_has_bug_14060
|
267
|
+
|
268
|
+
safe_test(:unavailable => :skip) do
|
265
269
|
identifier = 'Europe/Andorra'.dup.taint
|
266
270
|
assert(identifier.tainted?)
|
267
271
|
tz = Timezone.get(identifier)
|
@@ -271,6 +275,8 @@ class TCTimezone < Minitest::Test
|
|
271
275
|
end
|
272
276
|
|
273
277
|
def test_get_tainted_and_frozen_not_previously_loaded
|
278
|
+
skip_if_has_bug_14060
|
279
|
+
|
274
280
|
safe_test do
|
275
281
|
tz = Timezone.get('Europe/Amsterdam'.dup.taint.freeze)
|
276
282
|
assert_equal('Europe/Amsterdam', tz.identifier)
|
@@ -1260,6 +1266,7 @@ class TCTimezone < Minitest::Test
|
|
1260
1266
|
assert_equal('BST BST', tz.strftime('%Z %Z', dt))
|
1261
1267
|
assert_equal('BST %Z %BST %%Z %%BST', tz.strftime('%Z %%Z %%%Z %%%%Z %%%%%Z', dt))
|
1262
1268
|
assert_equal('+0100 +01:00 +01:00:00 +01 %::::z', tz.strftime('%z %:z %::z %:::z %::::z', dt))
|
1269
|
+
assert_equal('1153001522 %s %1153001522', tz.strftime('%s %%s %%%s', dt))
|
1263
1270
|
end
|
1264
1271
|
|
1265
1272
|
def test_strftime_time
|
@@ -1271,6 +1278,7 @@ class TCTimezone < Minitest::Test
|
|
1271
1278
|
assert_equal('BST BST', tz.strftime('%Z %Z', t))
|
1272
1279
|
assert_equal('BST %Z %BST %%Z %%BST', tz.strftime('%Z %%Z %%%Z %%%%Z %%%%%Z', t))
|
1273
1280
|
assert_equal('+0100 +01:00 +01:00:00 +01 %::::z', tz.strftime('%z %:z %::z %:::z %::::z', t))
|
1281
|
+
assert_equal('1153001522 %s %1153001522', tz.strftime('%s %%s %%%s', t))
|
1274
1282
|
end
|
1275
1283
|
|
1276
1284
|
def test_strftime_int
|
@@ -1282,6 +1290,7 @@ class TCTimezone < Minitest::Test
|
|
1282
1290
|
assert_equal('BST BST', tz.strftime('%Z %Z', i))
|
1283
1291
|
assert_equal('BST %Z %BST %%Z %%BST', tz.strftime('%Z %%Z %%%Z %%%%Z %%%%%Z', i))
|
1284
1292
|
assert_equal('+0100 +01:00 +01:00:00 +01 %::::z', tz.strftime('%z %:z %::z %:::z %::::z', i))
|
1293
|
+
assert_equal('1153001522 %s %1153001522', tz.strftime('%s %%s %%%s', i))
|
1285
1294
|
end
|
1286
1295
|
|
1287
1296
|
def test_get_missing_data_source
|
@@ -359,7 +359,17 @@ class TCTransitionDataTimezoneInfo < Minitest::Test
|
|
359
359
|
assert_equal([t1,t2,t3,t4,t5], dti.transitions_up_to(DateTime.new(2011,10,1,1,0,Rational(DATETIME_RESOLUTION,1000000))))
|
360
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
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
|
-
|
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
|
+
|
363
373
|
assert_equal([t5], dti.transitions_up_to(DateTime.new(2015,1,1,0,0,0), DateTime.new(2011,10,1,1,0,0)))
|
364
374
|
assert_equal([], dti.transitions_up_to(DateTime.new(2015,1,1,0,0,0), DateTime.new(2011,10,1,1,0,1)))
|
365
375
|
end
|
@@ -7,6 +7,15 @@ require 'tmpdir'
|
|
7
7
|
|
8
8
|
include TZInfo
|
9
9
|
|
10
|
+
# Use send as a workaround for an issue on JRuby 9.2.9.0 where using the
|
11
|
+
# refinement causes calls to RubyCoreSupport.file_open to fail to pass the block
|
12
|
+
# parameter.
|
13
|
+
#
|
14
|
+
# https://travis-ci.org/tzinfo/tzinfo/jobs/628812051#L1931
|
15
|
+
# https://github.com/jruby/jruby/issues/6009
|
16
|
+
send(:using, TZInfo::RubyCoreSupport::UntaintExt) if TZInfo::RubyCoreSupport.const_defined?(:UntaintExt)
|
17
|
+
send(:using, TaintExt) if Module.const_defined?(:TaintExt)
|
18
|
+
|
10
19
|
class TCZoneinfoDataSource < Minitest::Test
|
11
20
|
ZONEINFO_DIR = File.join(File.expand_path(File.dirname(__FILE__)), 'zoneinfo').untaint
|
12
21
|
|
@@ -653,7 +662,7 @@ class TCZoneinfoDataSource < Minitest::Test
|
|
653
662
|
end
|
654
663
|
|
655
664
|
def test_load_timezone_info_tainted
|
656
|
-
safe_test do
|
665
|
+
safe_test(:unavailable => :skip) do
|
657
666
|
identifier = 'Europe/Amsterdam'.dup.taint
|
658
667
|
assert(identifier.tainted?)
|
659
668
|
info = @data_source.load_timezone_info(identifier)
|
@@ -840,7 +849,7 @@ class TCZoneinfoDataSource < Minitest::Test
|
|
840
849
|
end
|
841
850
|
|
842
851
|
def test_load_country_info_tainted
|
843
|
-
safe_test do
|
852
|
+
safe_test(:unavailable => :skip) do
|
844
853
|
code = 'NL'.dup.taint
|
845
854
|
assert(code.tainted?)
|
846
855
|
info = @data_source.load_country_info(code)
|
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,8 +57,8 @@ 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
|
@@ -96,6 +98,16 @@ module Kernel
|
|
96
98
|
thread.join
|
97
99
|
end
|
98
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
|
99
111
|
|
100
112
|
def assert_array_same_items(expected, actual, msg = nil)
|
101
113
|
full_message = message(msg, '') { diff(expected, actual) }
|
@@ -152,6 +164,19 @@ module Kernel
|
|
152
164
|
end
|
153
165
|
|
154
166
|
|
167
|
+
# Object#taint is a deprecated no-op in Ruby 2.7 and outputs a warning. It will
|
168
|
+
# be removed in 3.0. Silence the warning or supply a replacement.
|
169
|
+
if TZInfo::RubyCoreSupport.const_defined?(:UntaintExt)
|
170
|
+
module TaintExt
|
171
|
+
refine Object do
|
172
|
+
def taint
|
173
|
+
self
|
174
|
+
end
|
175
|
+
end
|
176
|
+
end
|
177
|
+
end
|
178
|
+
|
179
|
+
|
155
180
|
# JRuby 1.7.5 to 1.7.9 consider DateTime instances that differ by less than
|
156
181
|
# 1 millisecond to be equivalent (https://github.com/jruby/jruby/issues/1311).
|
157
182
|
#
|
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,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'tzinfo'
|
3
|
-
s.version = '1.2.
|
3
|
+
s.version = '1.2.6'
|
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'
|
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.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Philip Ross
|
@@ -10,27 +10,26 @@ bindir: bin
|
|
10
10
|
cert_chain:
|
11
11
|
- |
|
12
12
|
-----BEGIN CERTIFICATE-----
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
IYlrSPqJ7q3pK9kchFKrrktRA6yVf+fR
|
13
|
+
MIIDPDCCAiSgAwIBAgIBATANBgkqhkiG9w0BAQsFADAkMSIwIAYDVQQDDBlwaGls
|
14
|
+
LnJvc3MvREM9Z21haWwvREM9Y29tMB4XDTE5MTIyNDE0NTU0N1oXDTM5MTIyNDE0
|
15
|
+
NTU0N1owJDEiMCAGA1UEAwwZcGhpbC5yb3NzL0RDPWdtYWlsL0RDPWNvbTCCASIw
|
16
|
+
DQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAJGcwfqn4ZsmPl0b1Lt9dCzExrE5
|
17
|
+
EeP/CRQjBdGHkF+mSpi69XysxdwLdfg5SPr9LfxthUug4nNFd5fDCiXM8hYe9jQD
|
18
|
+
TmkIQKNBh4fFpGngn9gyy+SumCXi6b5L6d/aMc59NAOM6LJ88TOdH1648dh5rq3C
|
19
|
+
ULq82n3gg4+u0HHGjRPuR/pnCFQCZbANYdX+UBWd0qkOJn/EreNKROmEeHr/xKuh
|
20
|
+
2/GlKFKt9KLcW3hwBB4fHHVYUzRau7D1m9KbEERdg//qNDC4B7fD2BFJuPbM5S7J
|
21
|
+
41VwDAh1O8B/Qpg0f+S83K4Kodw4MiPGsug55UkNtd3mGR/zZJ9WM03DSwkCAwEA
|
22
|
+
AaN5MHcwCQYDVR0TBAIwADALBgNVHQ8EBAMCBLAwHQYDVR0OBBYEFA+Z8zvfzBuA
|
23
|
+
esoHIfz7+jxfUOcfMB4GA1UdEQQXMBWBE3BoaWwucm9zc0BnbWFpbC5jb20wHgYD
|
24
|
+
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: 2019-12-24 00:00:00.000000000 Z
|
34
33
|
dependencies:
|
35
34
|
- !ruby/object:Gem::Dependency
|
36
35
|
name: thread_safe
|
@@ -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.7.4
|
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
|