tzinfo 1.2.5 → 2.0.0
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 +1 -3
- data.tar.gz.sig +0 -0
- data/.yardopts +3 -0
- data/CHANGES.md +469 -377
- data/LICENSE +12 -12
- data/README.md +368 -113
- data/lib/tzinfo.rb +60 -37
- data/lib/tzinfo/country.rb +131 -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 +141 -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 +573 -0
- data/lib/tzinfo/data_sources/zoneinfo_reader.rb +284 -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 +979 -498
- 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/version.rb +7 -0
- data/lib/tzinfo/with_offset.rb +61 -0
- metadata +62 -121
- metadata.gz.sig +2 -2
- 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 -146
- data/lib/tzinfo/ruby_country_info.rb +0 -74
- data/lib/tzinfo/ruby_data_source.rb +0 -136
- 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 -488
- data/lib/tzinfo/zoneinfo_timezone_info.rb +0 -296
- data/test/tc_country.rb +0 -234
- 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 -143
- data/test/tc_time_or_datetime.rb +0 -654
- data/test/tc_timezone.rb +0 -1350
- 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 -423
- data/test/tc_zoneinfo_country_info.rb +0 -78
- data/test/tc_zoneinfo_data_source.rb +0 -1195
- data/test/tc_zoneinfo_timezone_info.rb +0 -1232
- data/test/test_utils.rb +0 -163
- data/test/ts_all.rb +0 -7
- data/test/ts_all_ruby.rb +0 -5
- data/test/ts_all_zoneinfo.rb +0 -7
- 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
data/test/tc_timezone_proxy.rb
DELETED
@@ -1,136 +0,0 @@
|
|
1
|
-
require File.join(File.expand_path(File.dirname(__FILE__)), 'test_utils')
|
2
|
-
|
3
|
-
include TZInfo
|
4
|
-
|
5
|
-
class TCTimezoneProxy < Minitest::Test
|
6
|
-
def test_not_exist
|
7
|
-
proxy = TimezoneProxy.new('Nothing/Special')
|
8
|
-
t = Time.utc(2006,1,1,0,0,0)
|
9
|
-
assert_equal('Nothing/Special', proxy.identifier)
|
10
|
-
assert_equal('Nothing/Special', proxy.name)
|
11
|
-
assert_equal('Nothing - Special', proxy.friendly_identifier)
|
12
|
-
assert_equal('Nothing - Special', proxy.to_s)
|
13
|
-
|
14
|
-
assert_raises(InvalidTimezoneIdentifier) { proxy.canonical_identifier }
|
15
|
-
assert_raises(InvalidTimezoneIdentifier) { proxy.canonical_zone }
|
16
|
-
assert_raises(InvalidTimezoneIdentifier) { proxy.current_period }
|
17
|
-
assert_raises(InvalidTimezoneIdentifier) { proxy.current_period_and_time }
|
18
|
-
assert_raises(InvalidTimezoneIdentifier) { proxy.current_time_and_period }
|
19
|
-
assert_raises(InvalidTimezoneIdentifier) { proxy.local_to_utc(t) }
|
20
|
-
assert_raises(InvalidTimezoneIdentifier) { proxy.now }
|
21
|
-
assert_raises(InvalidTimezoneIdentifier) { proxy.offsets_up_to(t) }
|
22
|
-
assert_raises(InvalidTimezoneIdentifier) { proxy.period_for_local(t) }
|
23
|
-
assert_raises(InvalidTimezoneIdentifier) { proxy.period_for_utc(t) }
|
24
|
-
assert_raises(InvalidTimezoneIdentifier) { proxy.periods_for_local(t) }
|
25
|
-
assert_raises(InvalidTimezoneIdentifier) { proxy.strftime('%Z', t) }
|
26
|
-
assert_raises(InvalidTimezoneIdentifier) { proxy.transitions_up_to(t) }
|
27
|
-
assert_raises(InvalidTimezoneIdentifier) { proxy.utc_to_local(t) }
|
28
|
-
end
|
29
|
-
|
30
|
-
def test_valid
|
31
|
-
proxy = TimezoneProxy.new('Europe/London')
|
32
|
-
real = Timezone.get('Europe/London')
|
33
|
-
|
34
|
-
t1 = Time.utc(2005,8,1,0,0,0)
|
35
|
-
t2 = Time.utc(2004,8,1,0,0,0)
|
36
|
-
|
37
|
-
assert_equal(real.canonical_identifier, proxy.canonical_identifier)
|
38
|
-
assert_same(real.canonical_zone, proxy.canonical_zone)
|
39
|
-
assert_nothing_raised { proxy.current_period }
|
40
|
-
assert_nothing_raised { proxy.current_period_and_time }
|
41
|
-
assert_nothing_raised { proxy.current_time_and_period }
|
42
|
-
assert_equal(real.friendly_identifier(true), proxy.friendly_identifier(true))
|
43
|
-
assert_equal(real.friendly_identifier(false), proxy.friendly_identifier(false))
|
44
|
-
assert_equal(real.friendly_identifier, proxy.friendly_identifier)
|
45
|
-
assert_equal(real.identifier, proxy.identifier)
|
46
|
-
assert_equal(real.local_to_utc(t1), proxy.local_to_utc(t1))
|
47
|
-
assert_equal(real.name, proxy.name)
|
48
|
-
assert_nothing_raised { proxy.now }
|
49
|
-
assert_equal(real.offsets_up_to(t1), proxy.offsets_up_to(t1))
|
50
|
-
assert_equal(real.offsets_up_to(t1, t2), proxy.offsets_up_to(t1, t2))
|
51
|
-
assert_equal(real.period_for_local(t1), proxy.period_for_local(t1))
|
52
|
-
assert_equal(real.period_for_utc(t1), proxy.period_for_utc(t1))
|
53
|
-
assert_equal(real.periods_for_local(t1), proxy.periods_for_local(t1))
|
54
|
-
assert_equal(real.strftime('%Z', t1), proxy.strftime('%Z', t1))
|
55
|
-
assert_equal(real.to_s, proxy.to_s)
|
56
|
-
assert_equal(real.transitions_up_to(t1), proxy.transitions_up_to(t1))
|
57
|
-
assert_equal(real.transitions_up_to(t1, t2), proxy.transitions_up_to(t1, t2))
|
58
|
-
assert_equal(real.utc_to_local(t1), proxy.utc_to_local(t1))
|
59
|
-
|
60
|
-
|
61
|
-
assert(real == proxy)
|
62
|
-
assert(proxy == real)
|
63
|
-
assert_equal(0, real <=> proxy)
|
64
|
-
assert_equal(0, proxy <=> real)
|
65
|
-
end
|
66
|
-
|
67
|
-
def test_canonical_linked
|
68
|
-
# Test that the implementation of canonical_zone and canonical_identifier
|
69
|
-
# are actually calling the real timezone and not just returning it and
|
70
|
-
# its identifier.
|
71
|
-
|
72
|
-
real = Timezone.get('UTC')
|
73
|
-
proxy = TimezoneProxy.new('UTC')
|
74
|
-
|
75
|
-
# ZoneinfoDataSource doesn't return LinkedTimezoneInfo instances for any
|
76
|
-
# timezone.
|
77
|
-
if real.kind_of?(LinkedTimezone)
|
78
|
-
assert_equal('Etc/UTC', proxy.canonical_identifier)
|
79
|
-
assert_same(Timezone.get('Etc/UTC'), proxy.canonical_zone)
|
80
|
-
else
|
81
|
-
if DataSource.get.kind_of?(RubyDataSource)
|
82
|
-
# Not got a LinkedTimezone despite using a DataSource that supports it.
|
83
|
-
# Raise an exception as this shouldn't happen.
|
84
|
-
raise 'Non-LinkedTimezone instance returned for UTC using RubyDataSource'
|
85
|
-
end
|
86
|
-
|
87
|
-
assert_equal('UTC', proxy.canonical_identifier)
|
88
|
-
assert_same(Timezone.get('UTC'), proxy.canonical_zone)
|
89
|
-
end
|
90
|
-
end
|
91
|
-
|
92
|
-
def test_after_freeze
|
93
|
-
proxy = TimezoneProxy.new('Europe/London')
|
94
|
-
real = Timezone.get('Europe/London')
|
95
|
-
t = Time.utc(2017, 6, 1)
|
96
|
-
proxy.freeze
|
97
|
-
assert_equal('Europe/London', proxy.identifier)
|
98
|
-
assert_equal(real.utc_to_local(t), proxy.utc_to_local(t))
|
99
|
-
end
|
100
|
-
|
101
|
-
def test_equals
|
102
|
-
assert_equal(true, TimezoneProxy.new('Europe/London') == TimezoneProxy.new('Europe/London'))
|
103
|
-
assert_equal(false, TimezoneProxy.new('Europe/London') == TimezoneProxy.new('Europe/Paris'))
|
104
|
-
assert(!(TimezoneProxy.new('Europe/London') == Object.new))
|
105
|
-
end
|
106
|
-
|
107
|
-
def test_compare
|
108
|
-
assert_equal(0, TimezoneProxy.new('Europe/London') <=> TimezoneProxy.new('Europe/London'))
|
109
|
-
assert_equal(0, Timezone.get('Europe/London') <=> TimezoneProxy.new('Europe/London'))
|
110
|
-
assert_equal(0, TimezoneProxy.new('Europe/London') <=> Timezone.get('Europe/London'))
|
111
|
-
assert_equal(-1, TimezoneProxy.new('Europe/London') <=> TimezoneProxy.new('Europe/Paris'))
|
112
|
-
assert_equal(-1, Timezone.get('Europe/London') <=> TimezoneProxy.new('Europe/Paris'))
|
113
|
-
assert_equal(-1, TimezoneProxy.new('Europe/London') <=> Timezone.get('Europe/Paris'))
|
114
|
-
assert_equal(1, TimezoneProxy.new('Europe/Paris') <=> TimezoneProxy.new('Europe/London'))
|
115
|
-
assert_equal(1, Timezone.get('Europe/Paris') <=> TimezoneProxy.new('Europe/London'))
|
116
|
-
assert_equal(1, TimezoneProxy.new('Europe/Paris') <=> Timezone.get('Europe/London'))
|
117
|
-
assert_equal(-1, TimezoneProxy.new('America/New_York') <=> TimezoneProxy.new('Europe/Paris'))
|
118
|
-
assert_equal(-1, Timezone.get('America/New_York') <=> TimezoneProxy.new('Europe/Paris'))
|
119
|
-
assert_equal(-1, TimezoneProxy.new('America/New_York') <=> Timezone.get('Europe/Paris'))
|
120
|
-
assert_equal(1, TimezoneProxy.new('Europe/Paris') <=> TimezoneProxy.new('America/New_York'))
|
121
|
-
assert_equal(1, Timezone.get('Europe/Paris') <=> TimezoneProxy.new('America/New_York'))
|
122
|
-
assert_equal(1, TimezoneProxy.new('Europe/Paris') <=> Timezone.get('America/New_York'))
|
123
|
-
end
|
124
|
-
|
125
|
-
def test_kind
|
126
|
-
assert_kind_of(Timezone, TimezoneProxy.new('America/New_York'))
|
127
|
-
end
|
128
|
-
|
129
|
-
def test_marshal
|
130
|
-
tp = TimezoneProxy.new('Europe/London')
|
131
|
-
tp2 = Marshal.load(Marshal.dump(tp))
|
132
|
-
|
133
|
-
assert_kind_of(TimezoneProxy, tp2)
|
134
|
-
assert_equal('Europe/London', tp2.identifier)
|
135
|
-
end
|
136
|
-
end
|
@@ -1,366 +0,0 @@
|
|
1
|
-
require File.join(File.expand_path(File.dirname(__FILE__)), 'test_utils')
|
2
|
-
require 'date'
|
3
|
-
|
4
|
-
include TZInfo
|
5
|
-
|
6
|
-
class TCTimezoneTransition < Minitest::Test
|
7
|
-
|
8
|
-
class TestTimezoneTransition < TimezoneTransition
|
9
|
-
def initialize(offset, previous_offset, at)
|
10
|
-
super(offset, previous_offset)
|
11
|
-
@at = TimeOrDateTime.wrap(at)
|
12
|
-
end
|
13
|
-
|
14
|
-
def at
|
15
|
-
@at
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
def test_offset
|
20
|
-
t = TestTimezoneTransition.new(TimezoneOffset.new(3600, 3600, :TDT),
|
21
|
-
TimezoneOffset.new(3600, 0, :TST), 1148949080)
|
22
|
-
|
23
|
-
assert_equal(TimezoneOffset.new(3600, 3600, :TDT), t.offset)
|
24
|
-
end
|
25
|
-
|
26
|
-
def test_previous_offset
|
27
|
-
t = TestTimezoneTransition.new(TimezoneOffset.new(3600, 3600, :TDT),
|
28
|
-
TimezoneOffset.new(3600, 0, :TST), 1148949080)
|
29
|
-
|
30
|
-
assert_equal(TimezoneOffset.new(3600, 0, :TST), t.previous_offset)
|
31
|
-
end
|
32
|
-
|
33
|
-
def test_datetime
|
34
|
-
t1 = TestTimezoneTransition.new(TimezoneOffset.new(3600, 3600, :TDT),
|
35
|
-
TimezoneOffset.new(3600, 0, :TST), 1148949080)
|
36
|
-
t2 = TestTimezoneTransition.new(TimezoneOffset.new(3600, 3600, :TDT),
|
37
|
-
TimezoneOffset.new(3600, 0, :TST), DateTime.new(2006, 5, 30, 0, 31, 20))
|
38
|
-
t3 = TestTimezoneTransition.new(TimezoneOffset.new(3600, 3600, :TDT),
|
39
|
-
TimezoneOffset.new(3600, 0, :TST), Time.utc(2006, 5, 30, 0, 31, 20))
|
40
|
-
|
41
|
-
assert_equal(DateTime.new(2006, 5, 30, 0, 31, 20), t1.datetime)
|
42
|
-
assert_equal(DateTime.new(2006, 5, 30, 0, 31, 20), t2.datetime)
|
43
|
-
assert_equal(DateTime.new(2006, 5, 30, 0, 31, 20), t3.datetime)
|
44
|
-
end
|
45
|
-
|
46
|
-
def test_time
|
47
|
-
t1 = TestTimezoneTransition.new(TimezoneOffset.new(3600, 3600, :TDT),
|
48
|
-
TimezoneOffset.new(3600, 0, :TST), 1148949080)
|
49
|
-
t2 = TestTimezoneTransition.new(TimezoneOffset.new(3600, 3600, :TDT),
|
50
|
-
TimezoneOffset.new(3600, 0, :TST), DateTime.new(2006, 5, 30, 0, 31, 20))
|
51
|
-
t3 = TestTimezoneTransition.new(TimezoneOffset.new(3600, 3600, :TDT),
|
52
|
-
TimezoneOffset.new(3600, 0, :TST), Time.utc(2006, 5, 30, 0, 31, 20))
|
53
|
-
|
54
|
-
assert_equal(Time.utc(2006, 5, 30, 0, 31, 20), t1.time)
|
55
|
-
assert_equal(Time.utc(2006, 5, 30, 0, 31, 20), t2.time)
|
56
|
-
assert_equal(Time.utc(2006, 5, 30, 0, 31, 20), t3.time)
|
57
|
-
end
|
58
|
-
|
59
|
-
def test_local_end_at
|
60
|
-
t1 = TestTimezoneTransition.new(TimezoneOffset.new(3600, 3600, :TDT),
|
61
|
-
TimezoneOffset.new(3600, 0, :TST), 1148949080)
|
62
|
-
t2 = TestTimezoneTransition.new(TimezoneOffset.new(3600, 3600, :TDT),
|
63
|
-
TimezoneOffset.new(3600, 0, :TST), DateTime.new(2006, 5, 30, 0, 31, 20))
|
64
|
-
t3 = TestTimezoneTransition.new(TimezoneOffset.new(3600, 3600, :TDT),
|
65
|
-
TimezoneOffset.new(3600, 0, :TST), Time.utc(2006, 5, 30, 0, 31, 20))
|
66
|
-
|
67
|
-
assert(TimeOrDateTime.new(1148952680).eql?(t1.local_end_at))
|
68
|
-
assert(TimeOrDateTime.new(DateTime.new(2006, 5, 30, 1, 31, 20)).eql?(t2.local_end_at))
|
69
|
-
assert(TimeOrDateTime.new(Time.utc(2006, 5, 30, 1, 31, 20)).eql?(t3.local_end_at))
|
70
|
-
end
|
71
|
-
|
72
|
-
def test_local_end_at_after_freeze
|
73
|
-
t = TestTimezoneTransition.new(TimezoneOffset.new(3600, 3600, :TDT),
|
74
|
-
TimezoneOffset.new(3600, 0, :TST), 1148949080)
|
75
|
-
t.freeze
|
76
|
-
assert(TimeOrDateTime.new(1148952680).eql?(t.local_end_at))
|
77
|
-
end
|
78
|
-
|
79
|
-
def test_local_end
|
80
|
-
t1 = TestTimezoneTransition.new(TimezoneOffset.new(3600, 3600, :TDT),
|
81
|
-
TimezoneOffset.new(3600, 0, :TST), 1148949080)
|
82
|
-
t2 = TestTimezoneTransition.new(TimezoneOffset.new(3600, 3600, :TDT),
|
83
|
-
TimezoneOffset.new(3600, 0, :TST), DateTime.new(2006, 5, 30, 0, 31, 20))
|
84
|
-
t3 = TestTimezoneTransition.new(TimezoneOffset.new(3600, 3600, :TDT),
|
85
|
-
TimezoneOffset.new(3600, 0, :TST), Time.utc(2006, 5, 30, 0, 31, 20))
|
86
|
-
|
87
|
-
assert_equal(DateTime.new(2006, 5, 30, 1, 31, 20), t1.local_end)
|
88
|
-
assert_equal(DateTime.new(2006, 5, 30, 1, 31, 20), t2.local_end)
|
89
|
-
assert_equal(DateTime.new(2006, 5, 30, 1, 31, 20), t3.local_end)
|
90
|
-
end
|
91
|
-
|
92
|
-
def test_local_end_time
|
93
|
-
t1 = TestTimezoneTransition.new(TimezoneOffset.new(3600, 3600, :TDT),
|
94
|
-
TimezoneOffset.new(3600, 0, :TST), 1148949080)
|
95
|
-
t2 = TestTimezoneTransition.new(TimezoneOffset.new(3600, 3600, :TDT),
|
96
|
-
TimezoneOffset.new(3600, 0, :TST), DateTime.new(2006, 5, 30, 0, 31, 20))
|
97
|
-
t3 = TestTimezoneTransition.new(TimezoneOffset.new(3600, 3600, :TDT),
|
98
|
-
TimezoneOffset.new(3600, 0, :TST), Time.utc(2006, 5, 30, 0, 31, 20))
|
99
|
-
|
100
|
-
assert_equal(Time.utc(2006, 5, 30, 1, 31, 20), t1.local_end_time)
|
101
|
-
assert_equal(Time.utc(2006, 5, 30, 1, 31, 20), t2.local_end_time)
|
102
|
-
assert_equal(Time.utc(2006, 5, 30, 1, 31, 20), t3.local_end_time)
|
103
|
-
end
|
104
|
-
|
105
|
-
def test_local_start_at
|
106
|
-
t1 = TestTimezoneTransition.new(TimezoneOffset.new(3600, 3600, :TDT),
|
107
|
-
TimezoneOffset.new(3600, 0, :TST), 1148949080)
|
108
|
-
t2 = TestTimezoneTransition.new(TimezoneOffset.new(3600, 3600, :TDT),
|
109
|
-
TimezoneOffset.new(3600, 0, :TST), DateTime.new(2006, 5, 30, 0, 31, 20))
|
110
|
-
t3 = TestTimezoneTransition.new(TimezoneOffset.new(3600, 3600, :TDT),
|
111
|
-
TimezoneOffset.new(3600, 0, :TST), Time.utc(2006, 5, 30, 0, 31, 20))
|
112
|
-
|
113
|
-
assert(TimeOrDateTime.new(1148956280).eql?(t1.local_start_at))
|
114
|
-
assert(TimeOrDateTime.new(DateTime.new(2006, 5, 30, 2, 31, 20)).eql?(t2.local_start_at))
|
115
|
-
assert(TimeOrDateTime.new(Time.utc(2006, 5, 30, 2, 31, 20)).eql?(t3.local_start_at))
|
116
|
-
end
|
117
|
-
|
118
|
-
def test_local_start_at_after_freeze
|
119
|
-
t = TestTimezoneTransition.new(TimezoneOffset.new(3600, 3600, :TDT),
|
120
|
-
TimezoneOffset.new(3600, 0, :TST), 1148949080)
|
121
|
-
t.freeze
|
122
|
-
assert(TimeOrDateTime.new(1148956280).eql?(t.local_start_at))
|
123
|
-
end
|
124
|
-
|
125
|
-
def test_local_start
|
126
|
-
t1 = TestTimezoneTransition.new(TimezoneOffset.new(3600, 3600, :TDT),
|
127
|
-
TimezoneOffset.new(3600, 0, :TST), 1148949080)
|
128
|
-
t2 = TestTimezoneTransition.new(TimezoneOffset.new(3600, 3600, :TDT),
|
129
|
-
TimezoneOffset.new(3600, 0, :TST), DateTime.new(2006, 5, 30, 0, 31, 20))
|
130
|
-
t3 = TestTimezoneTransition.new(TimezoneOffset.new(3600, 3600, :TDT),
|
131
|
-
TimezoneOffset.new(3600, 0, :TST), Time.utc(2006, 5, 30, 0, 31, 20))
|
132
|
-
|
133
|
-
assert_equal(DateTime.new(2006, 5, 30, 2, 31, 20), t1.local_start)
|
134
|
-
assert_equal(DateTime.new(2006, 5, 30, 2, 31, 20), t2.local_start)
|
135
|
-
assert_equal(DateTime.new(2006, 5, 30, 2, 31, 20), t3.local_start)
|
136
|
-
end
|
137
|
-
|
138
|
-
def test_local_start_time
|
139
|
-
t1 = TestTimezoneTransition.new(TimezoneOffset.new(3600, 3600, :TDT),
|
140
|
-
TimezoneOffset.new(3600, 0, :TST), 1148949080)
|
141
|
-
t2 = TestTimezoneTransition.new(TimezoneOffset.new(3600, 3600, :TDT),
|
142
|
-
TimezoneOffset.new(3600, 0, :TST), DateTime.new(2006, 5, 30, 0, 31, 20))
|
143
|
-
t3 = TestTimezoneTransition.new(TimezoneOffset.new(3600, 3600, :TDT),
|
144
|
-
TimezoneOffset.new(3600, 0, :TST), Time.utc(2006, 5, 30, 0, 31, 20))
|
145
|
-
|
146
|
-
assert_equal(Time.utc(2006, 5, 30, 2, 31, 20), t1.local_start_time)
|
147
|
-
assert_equal(Time.utc(2006, 5, 30, 2, 31, 20), t2.local_start_time)
|
148
|
-
assert_equal(Time.utc(2006, 5, 30, 2, 31, 20), t3.local_start_time)
|
149
|
-
end
|
150
|
-
|
151
|
-
if RubyCoreSupport.time_supports_negative
|
152
|
-
def test_local_end_at_before_negative_32bit
|
153
|
-
t = TestTimezoneTransition.new(TimezoneOffset.new(-7200, 3600, :TDT),
|
154
|
-
TimezoneOffset.new(-7200, 0, :TST), -2147482800)
|
155
|
-
|
156
|
-
if RubyCoreSupport.time_supports_64bit
|
157
|
-
assert(TimeOrDateTime.new(-2147490000).eql?(t.local_end_at))
|
158
|
-
else
|
159
|
-
assert(TimeOrDateTime.new(DateTime.new(1901, 12, 13, 19, 0, 0)).eql?(t.local_end_at))
|
160
|
-
end
|
161
|
-
end
|
162
|
-
|
163
|
-
def test_local_start_at_before_negative_32bit
|
164
|
-
t = TestTimezoneTransition.new(TimezoneOffset.new(-7200, 3600, :TDT),
|
165
|
-
TimezoneOffset.new(-7200, 0, :TST), -2147482800)
|
166
|
-
|
167
|
-
if RubyCoreSupport.time_supports_64bit
|
168
|
-
assert(TimeOrDateTime.new(-2147486400).eql?(t.local_start_at))
|
169
|
-
else
|
170
|
-
assert(TimeOrDateTime.new(DateTime.new(1901, 12, 13, 20, 0, 0)).eql?(t.local_start_at))
|
171
|
-
end
|
172
|
-
end
|
173
|
-
end
|
174
|
-
|
175
|
-
def test_local_end_at_before_epoch
|
176
|
-
t = TestTimezoneTransition.new(TimezoneOffset.new(-7200, 3600, :TDT),
|
177
|
-
TimezoneOffset.new(-7200, 0, :TST), 1800)
|
178
|
-
|
179
|
-
if RubyCoreSupport.time_supports_negative
|
180
|
-
assert(TimeOrDateTime.new(-5400).eql?(t.local_end_at))
|
181
|
-
else
|
182
|
-
assert(TimeOrDateTime.new(DateTime.new(1969, 12, 31, 22, 30, 0)).eql?(t.local_end_at))
|
183
|
-
end
|
184
|
-
end
|
185
|
-
|
186
|
-
def test_local_start_at_before_epoch
|
187
|
-
t = TestTimezoneTransition.new(TimezoneOffset.new(-7200, 3600, :TDT),
|
188
|
-
TimezoneOffset.new(-7200, 0, :TST), 1800)
|
189
|
-
|
190
|
-
if RubyCoreSupport.time_supports_negative
|
191
|
-
assert(TimeOrDateTime.new(-1800).eql?(t.local_start_at))
|
192
|
-
else
|
193
|
-
assert(TimeOrDateTime.new(DateTime.new(1969, 12, 31, 23, 30, 0)).eql?(t.local_start_at))
|
194
|
-
end
|
195
|
-
end
|
196
|
-
|
197
|
-
def test_local_end_at_after_32bit
|
198
|
-
t = TestTimezoneTransition.new(TimezoneOffset.new(3600, 3600, :TDT),
|
199
|
-
TimezoneOffset.new(3600, 0, :TST), 2147482800)
|
200
|
-
|
201
|
-
if RubyCoreSupport.time_supports_64bit
|
202
|
-
assert(TimeOrDateTime.new(2147486400).eql?(t.local_end_at))
|
203
|
-
else
|
204
|
-
assert(TimeOrDateTime.new(DateTime.new(2038, 1, 19, 4, 0, 0)).eql?(t.local_end_at))
|
205
|
-
end
|
206
|
-
end
|
207
|
-
|
208
|
-
def test_local_start_at_after_32bit
|
209
|
-
t = TestTimezoneTransition.new(TimezoneOffset.new(3600, 3600, :TDT),
|
210
|
-
TimezoneOffset.new(3600, 0, :TST), 2147482800)
|
211
|
-
|
212
|
-
if RubyCoreSupport.time_supports_64bit
|
213
|
-
assert(TimeOrDateTime.new(2147490000).eql?(t.local_start_at))
|
214
|
-
else
|
215
|
-
assert(TimeOrDateTime.new(DateTime.new(2038, 1, 19, 5, 0, 0)).eql?(t.local_start_at))
|
216
|
-
end
|
217
|
-
end
|
218
|
-
|
219
|
-
def test_equality_timestamp
|
220
|
-
t1 = TestTimezoneTransition.new(TimezoneOffset.new(3600, 3600, :TDT),
|
221
|
-
TimezoneOffset.new(3600, 0, :TST), 1148949080)
|
222
|
-
t2 = TestTimezoneTransition.new(TimezoneOffset.new(3600, 3600, :TDT),
|
223
|
-
TimezoneOffset.new(3600, 0, :TST), 1148949080)
|
224
|
-
t3 = TestTimezoneTransition.new(TimezoneOffset.new(3600, 3600, :TDT),
|
225
|
-
TimezoneOffset.new(3600, 0, :TST), DateTime.new(2006, 5, 30, 0, 31, 20))
|
226
|
-
t4 = TestTimezoneTransition.new(TimezoneOffset.new(3600, 3600, :TDT),
|
227
|
-
TimezoneOffset.new(3600, 0, :TST), Time.utc(2006, 5, 30, 0, 31, 20))
|
228
|
-
t5 = TestTimezoneTransition.new(TimezoneOffset.new(3600, 3600, :TDT),
|
229
|
-
TimezoneOffset.new(3600, 0, :TST), 1148949081)
|
230
|
-
t6 = TestTimezoneTransition.new(TimezoneOffset.new(3600, 3600, :TDT),
|
231
|
-
TimezoneOffset.new(3600, 0, :TST), DateTime.new(2006, 5, 30, 1, 31, 21))
|
232
|
-
t7 = TestTimezoneTransition.new(TimezoneOffset.new(3600, 3600, :TDT),
|
233
|
-
TimezoneOffset.new(3600, 0, :TST), Time.utc(2006, 5, 30, 1, 31, 21))
|
234
|
-
t8 = TestTimezoneTransition.new(TimezoneOffset.new(3601, 3600, :TDT),
|
235
|
-
TimezoneOffset.new(3600, 0, :TST), 1148949080)
|
236
|
-
t9 = TestTimezoneTransition.new(TimezoneOffset.new(3600, 3600, :TDT),
|
237
|
-
TimezoneOffset.new(3601, 0, :TST), 1148949080)
|
238
|
-
|
239
|
-
assert_equal(true, t1 == t1)
|
240
|
-
assert_equal(true, t1 == t2)
|
241
|
-
assert_equal(true, t1 == t3)
|
242
|
-
assert_equal(true, t1 == t4)
|
243
|
-
assert_equal(false, t1 == t5)
|
244
|
-
assert_equal(false, t1 == t6)
|
245
|
-
assert_equal(false, t1 == t7)
|
246
|
-
assert_equal(false, t1 == t8)
|
247
|
-
assert_equal(false, t1 == t9)
|
248
|
-
assert_equal(false, t1 == Object.new)
|
249
|
-
|
250
|
-
assert_equal(true, t1.eql?(t1))
|
251
|
-
assert_equal(true, t1.eql?(t2))
|
252
|
-
assert_equal(false, t1.eql?(t3))
|
253
|
-
assert_equal(false, t1.eql?(t4))
|
254
|
-
assert_equal(false, t1.eql?(t5))
|
255
|
-
assert_equal(false, t1.eql?(t6))
|
256
|
-
assert_equal(false, t1.eql?(t7))
|
257
|
-
assert_equal(false, t1.eql?(t8))
|
258
|
-
assert_equal(false, t1.eql?(t9))
|
259
|
-
assert_equal(false, t1.eql?(Object.new))
|
260
|
-
end
|
261
|
-
|
262
|
-
def test_equality_datetime
|
263
|
-
t1 = TestTimezoneTransition.new(TimezoneOffset.new(3600, 3600, :TDT),
|
264
|
-
TimezoneOffset.new(3600, 0, :TST), DateTime.new(2006, 5, 30, 0, 31, 20))
|
265
|
-
t2 = TestTimezoneTransition.new(TimezoneOffset.new(3600, 3600, :TDT),
|
266
|
-
TimezoneOffset.new(3600, 0, :TST), DateTime.new(2006, 5, 30, 0, 31, 20))
|
267
|
-
t3 = TestTimezoneTransition.new(TimezoneOffset.new(3600, 3600, :TDT),
|
268
|
-
TimezoneOffset.new(3600, 0, :TST), 1148949080)
|
269
|
-
t4 = TestTimezoneTransition.new(TimezoneOffset.new(3600, 3600, :TDT),
|
270
|
-
TimezoneOffset.new(3600, 0, :TST), Time.utc(2006, 5, 30, 0, 31, 20))
|
271
|
-
t5 = TestTimezoneTransition.new(TimezoneOffset.new(3600, 3600, :TDT),
|
272
|
-
TimezoneOffset.new(3600, 0, :TST), DateTime.new(2006, 5, 30, 1, 31, 21))
|
273
|
-
t6 = TestTimezoneTransition.new(TimezoneOffset.new(3600, 3600, :TDT),
|
274
|
-
TimezoneOffset.new(3600, 0, :TST), 1148949081)
|
275
|
-
t7 = TestTimezoneTransition.new(TimezoneOffset.new(3600, 3600, :TDT),
|
276
|
-
TimezoneOffset.new(3600, 0, :TST), Time.utc(2006, 5, 30, 1, 31, 21))
|
277
|
-
t8 = TestTimezoneTransition.new(TimezoneOffset.new(3601, 3600, :TDT),
|
278
|
-
TimezoneOffset.new(3600, 0, :TST), DateTime.new(2006, 5, 30, 0, 31, 20))
|
279
|
-
t9 = TestTimezoneTransition.new(TimezoneOffset.new(3600, 3600, :TDT),
|
280
|
-
TimezoneOffset.new(3601, 0, :TST), DateTime.new(2006, 5, 30, 0, 31, 20))
|
281
|
-
|
282
|
-
assert_equal(true, t1 == t1)
|
283
|
-
assert_equal(true, t1 == t2)
|
284
|
-
assert_equal(true, t1 == t3)
|
285
|
-
assert_equal(true, t1 == t4)
|
286
|
-
assert_equal(false, t1 == t5)
|
287
|
-
assert_equal(false, t1 == t6)
|
288
|
-
assert_equal(false, t1 == t7)
|
289
|
-
assert_equal(false, t1 == t8)
|
290
|
-
assert_equal(false, t1 == t9)
|
291
|
-
assert_equal(false, t1 == Object.new)
|
292
|
-
|
293
|
-
assert_equal(true, t1.eql?(t1))
|
294
|
-
assert_equal(true, t1.eql?(t2))
|
295
|
-
assert_equal(false, t1.eql?(t3))
|
296
|
-
assert_equal(false, t1.eql?(t4))
|
297
|
-
assert_equal(false, t1.eql?(t5))
|
298
|
-
assert_equal(false, t1.eql?(t6))
|
299
|
-
assert_equal(false, t1.eql?(t7))
|
300
|
-
assert_equal(false, t1.eql?(t8))
|
301
|
-
assert_equal(false, t1.eql?(t9))
|
302
|
-
assert_equal(false, t1.eql?(Object.new))
|
303
|
-
end
|
304
|
-
|
305
|
-
def test_equality_time
|
306
|
-
t1 = TestTimezoneTransition.new(TimezoneOffset.new(3600, 3600, :TDT),
|
307
|
-
TimezoneOffset.new(3600, 0, :TST), Time.utc(2006, 5, 30, 0, 31, 20))
|
308
|
-
t2 = TestTimezoneTransition.new(TimezoneOffset.new(3600, 3600, :TDT),
|
309
|
-
TimezoneOffset.new(3600, 0, :TST), Time.utc(2006, 5, 30, 0, 31, 20))
|
310
|
-
t3 = TestTimezoneTransition.new(TimezoneOffset.new(3600, 3600, :TDT),
|
311
|
-
TimezoneOffset.new(3600, 0, :TST), DateTime.new(2006, 5, 30, 0, 31, 20))
|
312
|
-
t4 = TestTimezoneTransition.new(TimezoneOffset.new(3600, 3600, :TDT),
|
313
|
-
TimezoneOffset.new(3600, 0, :TST), 1148949080)
|
314
|
-
t5 = TestTimezoneTransition.new(TimezoneOffset.new(3600, 3600, :TDT),
|
315
|
-
TimezoneOffset.new(3600, 0, :TST), Time.utc(2006, 5, 30, 0, 31, 21))
|
316
|
-
t6 = TestTimezoneTransition.new(TimezoneOffset.new(3600, 3600, :TDT),
|
317
|
-
TimezoneOffset.new(3600, 0, :TST), DateTime.new(2006, 5, 30, 1, 31, 21))
|
318
|
-
t7 = TestTimezoneTransition.new(TimezoneOffset.new(3600, 3600, :TDT),
|
319
|
-
TimezoneOffset.new(3600, 0, :TST), 1148949081)
|
320
|
-
t8 = TestTimezoneTransition.new(TimezoneOffset.new(3601, 3600, :TDT),
|
321
|
-
TimezoneOffset.new(3600, 0, :TST), 1148949080)
|
322
|
-
t9 = TestTimezoneTransition.new(TimezoneOffset.new(3600, 3600, :TDT),
|
323
|
-
TimezoneOffset.new(3601, 0, :TST), 1148949080)
|
324
|
-
|
325
|
-
assert_equal(true, t1 == t1)
|
326
|
-
assert_equal(true, t1 == t2)
|
327
|
-
assert_equal(true, t1 == t3)
|
328
|
-
assert_equal(true, t1 == t4)
|
329
|
-
assert_equal(false, t1 == t5)
|
330
|
-
assert_equal(false, t1 == t6)
|
331
|
-
assert_equal(false, t1 == t7)
|
332
|
-
assert_equal(false, t1 == t8)
|
333
|
-
assert_equal(false, t1 == t9)
|
334
|
-
assert_equal(false, t1 == Object.new)
|
335
|
-
|
336
|
-
assert_equal(true, t1.eql?(t1))
|
337
|
-
assert_equal(true, t1.eql?(t2))
|
338
|
-
assert_equal(false, t1.eql?(t3))
|
339
|
-
assert_equal(false, t1.eql?(t4))
|
340
|
-
assert_equal(false, t1.eql?(t5))
|
341
|
-
assert_equal(false, t1.eql?(t6))
|
342
|
-
assert_equal(false, t1.eql?(t7))
|
343
|
-
assert_equal(false, t1.eql?(t8))
|
344
|
-
assert_equal(false, t1.eql?(t9))
|
345
|
-
assert_equal(false, t1.eql?(Object.new))
|
346
|
-
end
|
347
|
-
|
348
|
-
def test_hash
|
349
|
-
t1 = TestTimezoneTransition.new(TimezoneOffset.new(3600, 3600, :TDTA),
|
350
|
-
TimezoneOffset.new(3600, 0, :TSTA), 1148949080)
|
351
|
-
t2 = TestTimezoneTransition.new(TimezoneOffset.new(3600, 3600, :TDTB),
|
352
|
-
TimezoneOffset.new(3600, 0, :TSTB), DateTime.new(2006, 5, 30, 1, 31, 20))
|
353
|
-
t3 = TestTimezoneTransition.new(TimezoneOffset.new(3600, 3600, :TDTC),
|
354
|
-
TimezoneOffset.new(3600, 0, :TSTC), Time.utc(2006, 5, 30, 1, 31, 20))
|
355
|
-
|
356
|
-
assert_equal(TimezoneOffset.new(3600, 3600, :TDTA).hash ^
|
357
|
-
TimezoneOffset.new(3600, 0, :TSTA).hash ^ TimeOrDateTime.new(1148949080).hash,
|
358
|
-
t1.hash)
|
359
|
-
assert_equal(TimezoneOffset.new(3600, 3600, :TDTB).hash ^
|
360
|
-
TimezoneOffset.new(3600, 0, :TSTB).hash ^ TimeOrDateTime.new(DateTime.new(2006, 5, 30, 1, 31, 20)).hash,
|
361
|
-
t2.hash)
|
362
|
-
assert_equal(TimezoneOffset.new(3600, 3600, :TDTC).hash ^
|
363
|
-
TimezoneOffset.new(3600, 0, :TSTC).hash ^ TimeOrDateTime.new(Time.utc(2006, 5, 30, 1, 31, 20)).hash,
|
364
|
-
t3.hash)
|
365
|
-
end
|
366
|
-
end
|