tzinfo 1.2.6 → 2.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +1 -1
- data/.yardopts +3 -0
- data/CHANGES.md +494 -380
- data/LICENSE +13 -13
- data/README.md +368 -114
- data/lib/tzinfo.rb +59 -29
- data/lib/tzinfo/country.rb +141 -129
- data/lib/tzinfo/country_timezone.rb +70 -112
- data/lib/tzinfo/data_source.rb +389 -144
- data/lib/tzinfo/data_sources.rb +8 -0
- data/lib/tzinfo/data_sources/constant_offset_data_timezone_info.rb +56 -0
- data/lib/tzinfo/data_sources/country_info.rb +42 -0
- data/lib/tzinfo/data_sources/data_timezone_info.rb +91 -0
- data/lib/tzinfo/data_sources/linked_timezone_info.rb +33 -0
- data/lib/tzinfo/data_sources/ruby_data_source.rb +145 -0
- data/lib/tzinfo/data_sources/timezone_info.rb +47 -0
- data/lib/tzinfo/data_sources/transitions_data_timezone_info.rb +214 -0
- data/lib/tzinfo/data_sources/zoneinfo_data_source.rb +577 -0
- data/lib/tzinfo/data_sources/zoneinfo_reader.rb +288 -0
- data/lib/tzinfo/data_timezone.rb +33 -47
- data/lib/tzinfo/datetime_with_offset.rb +153 -0
- data/lib/tzinfo/format1.rb +10 -0
- data/lib/tzinfo/format1/country_definer.rb +17 -0
- data/lib/tzinfo/format1/country_index_definition.rb +64 -0
- data/lib/tzinfo/format1/timezone_definer.rb +64 -0
- data/lib/tzinfo/format1/timezone_definition.rb +39 -0
- data/lib/tzinfo/format1/timezone_index_definition.rb +77 -0
- data/lib/tzinfo/format2.rb +10 -0
- data/lib/tzinfo/format2/country_definer.rb +68 -0
- data/lib/tzinfo/format2/country_index_definer.rb +68 -0
- data/lib/tzinfo/format2/country_index_definition.rb +46 -0
- data/lib/tzinfo/format2/timezone_definer.rb +94 -0
- data/lib/tzinfo/format2/timezone_definition.rb +73 -0
- data/lib/tzinfo/format2/timezone_index_definer.rb +45 -0
- data/lib/tzinfo/format2/timezone_index_definition.rb +55 -0
- data/lib/tzinfo/info_timezone.rb +26 -21
- data/lib/tzinfo/linked_timezone.rb +33 -52
- data/lib/tzinfo/offset_timezone_period.rb +42 -0
- data/lib/tzinfo/string_deduper.rb +118 -0
- data/lib/tzinfo/time_with_offset.rb +128 -0
- data/lib/tzinfo/timestamp.rb +548 -0
- data/lib/tzinfo/timestamp_with_offset.rb +85 -0
- data/lib/tzinfo/timezone.rb +989 -502
- data/lib/tzinfo/timezone_offset.rb +84 -74
- data/lib/tzinfo/timezone_period.rb +151 -217
- data/lib/tzinfo/timezone_proxy.rb +70 -79
- data/lib/tzinfo/timezone_transition.rb +77 -109
- data/lib/tzinfo/transitions_timezone_period.rb +63 -0
- data/lib/tzinfo/untaint_ext.rb +18 -0
- data/lib/tzinfo/version.rb +7 -0
- data/lib/tzinfo/with_offset.rb +61 -0
- metadata +44 -100
- metadata.gz.sig +0 -0
- data/Rakefile +0 -107
- data/lib/tzinfo/country_index_definition.rb +0 -31
- data/lib/tzinfo/country_info.rb +0 -42
- data/lib/tzinfo/data_timezone_info.rb +0 -55
- data/lib/tzinfo/linked_timezone_info.rb +0 -26
- data/lib/tzinfo/offset_rationals.rb +0 -77
- data/lib/tzinfo/ruby_core_support.rb +0 -176
- data/lib/tzinfo/ruby_country_info.rb +0 -74
- data/lib/tzinfo/ruby_data_source.rb +0 -138
- data/lib/tzinfo/time_or_datetime.rb +0 -340
- data/lib/tzinfo/timezone_definition.rb +0 -36
- data/lib/tzinfo/timezone_index_definition.rb +0 -54
- data/lib/tzinfo/timezone_info.rb +0 -30
- data/lib/tzinfo/timezone_transition_definition.rb +0 -104
- data/lib/tzinfo/transition_data_timezone_info.rb +0 -274
- data/lib/tzinfo/zoneinfo_country_info.rb +0 -37
- data/lib/tzinfo/zoneinfo_data_source.rb +0 -496
- data/lib/tzinfo/zoneinfo_timezone_info.rb +0 -298
- data/test/tc_country.rb +0 -236
- data/test/tc_country_index_definition.rb +0 -69
- data/test/tc_country_info.rb +0 -16
- data/test/tc_country_timezone.rb +0 -173
- data/test/tc_data_source.rb +0 -218
- data/test/tc_data_timezone.rb +0 -99
- data/test/tc_data_timezone_info.rb +0 -18
- data/test/tc_info_timezone.rb +0 -34
- data/test/tc_linked_timezone.rb +0 -155
- data/test/tc_linked_timezone_info.rb +0 -23
- data/test/tc_offset_rationals.rb +0 -23
- data/test/tc_ruby_core_support.rb +0 -168
- data/test/tc_ruby_country_info.rb +0 -110
- data/test/tc_ruby_data_source.rb +0 -165
- data/test/tc_time_or_datetime.rb +0 -660
- data/test/tc_timezone.rb +0 -1359
- data/test/tc_timezone_definition.rb +0 -113
- data/test/tc_timezone_index_definition.rb +0 -73
- data/test/tc_timezone_info.rb +0 -11
- data/test/tc_timezone_london.rb +0 -143
- data/test/tc_timezone_melbourne.rb +0 -142
- data/test/tc_timezone_new_york.rb +0 -142
- data/test/tc_timezone_offset.rb +0 -126
- data/test/tc_timezone_period.rb +0 -555
- data/test/tc_timezone_proxy.rb +0 -136
- data/test/tc_timezone_transition.rb +0 -366
- data/test/tc_timezone_transition_definition.rb +0 -295
- data/test/tc_timezone_utc.rb +0 -27
- data/test/tc_transition_data_timezone_info.rb +0 -433
- data/test/tc_zoneinfo_country_info.rb +0 -78
- data/test/tc_zoneinfo_data_source.rb +0 -1204
- data/test/tc_zoneinfo_timezone_info.rb +0 -1234
- data/test/test_utils.rb +0 -188
- data/test/ts_all.rb +0 -7
- data/test/ts_all_ruby.rb +0 -5
- data/test/ts_all_zoneinfo.rb +0 -9
- data/test/tzinfo-data/tzinfo/data.rb +0 -8
- data/test/tzinfo-data/tzinfo/data/definitions/America/Argentina/Buenos_Aires.rb +0 -89
- data/test/tzinfo-data/tzinfo/data/definitions/America/New_York.rb +0 -315
- data/test/tzinfo-data/tzinfo/data/definitions/Australia/Melbourne.rb +0 -218
- data/test/tzinfo-data/tzinfo/data/definitions/EST.rb +0 -19
- data/test/tzinfo-data/tzinfo/data/definitions/Etc/GMT__m__1.rb +0 -21
- data/test/tzinfo-data/tzinfo/data/definitions/Etc/GMT__p__1.rb +0 -21
- data/test/tzinfo-data/tzinfo/data/definitions/Etc/UTC.rb +0 -21
- data/test/tzinfo-data/tzinfo/data/definitions/Europe/Amsterdam.rb +0 -261
- data/test/tzinfo-data/tzinfo/data/definitions/Europe/Andorra.rb +0 -186
- data/test/tzinfo-data/tzinfo/data/definitions/Europe/London.rb +0 -321
- data/test/tzinfo-data/tzinfo/data/definitions/Europe/Paris.rb +0 -265
- data/test/tzinfo-data/tzinfo/data/definitions/Europe/Prague.rb +0 -220
- data/test/tzinfo-data/tzinfo/data/definitions/UTC.rb +0 -16
- data/test/tzinfo-data/tzinfo/data/indexes/countries.rb +0 -927
- data/test/tzinfo-data/tzinfo/data/indexes/timezones.rb +0 -596
- data/test/tzinfo-data/tzinfo/data/version.rb +0 -14
- data/test/zoneinfo/America/Argentina/Buenos_Aires +0 -0
- data/test/zoneinfo/America/New_York +0 -0
- data/test/zoneinfo/Australia/Melbourne +0 -0
- data/test/zoneinfo/EST +0 -0
- data/test/zoneinfo/Etc/UTC +0 -0
- data/test/zoneinfo/Europe/Amsterdam +0 -0
- data/test/zoneinfo/Europe/Andorra +0 -0
- data/test/zoneinfo/Europe/London +0 -0
- data/test/zoneinfo/Europe/Paris +0 -0
- data/test/zoneinfo/Europe/Prague +0 -0
- data/test/zoneinfo/Factory +0 -0
- data/test/zoneinfo/iso3166.tab +0 -275
- data/test/zoneinfo/leapseconds +0 -61
- data/test/zoneinfo/posix/Europe/London +0 -0
- data/test/zoneinfo/posixrules +0 -0
- data/test/zoneinfo/right/Europe/London +0 -0
- data/test/zoneinfo/zone.tab +0 -439
- data/test/zoneinfo/zone1970.tab +0 -369
- data/tzinfo.gemspec +0 -21
@@ -1,142 +0,0 @@
|
|
1
|
-
require File.join(File.expand_path(File.dirname(__FILE__)), 'test_utils')
|
2
|
-
|
3
|
-
include TZInfo
|
4
|
-
|
5
|
-
class TCTimezoneNewYork < Minitest::Test
|
6
|
-
def test_2004
|
7
|
-
#America/New_York Sun Apr 4 06:59:59 2004 UTC = Sun Apr 4 01:59:59 2004 EST isdst=0 gmtoff=-18000
|
8
|
-
#America/New_York Sun Apr 4 07:00:00 2004 UTC = Sun Apr 4 03:00:00 2004 EDT isdst=1 gmtoff=-14400
|
9
|
-
#America/New_York Sun Oct 31 05:59:59 2004 UTC = Sun Oct 31 01:59:59 2004 EDT isdst=1 gmtoff=-14400
|
10
|
-
#America/New_York Sun Oct 31 06:00:00 2004 UTC = Sun Oct 31 01:00:00 2004 EST isdst=0 gmtoff=-18000
|
11
|
-
|
12
|
-
tz = Timezone.get('America/New_York')
|
13
|
-
assert_equal(DateTime.new(2004,4,4,1,59,59), tz.utc_to_local(DateTime.new(2004,4,4,6,59,59)))
|
14
|
-
assert_equal(DateTime.new(2004,4,4,3,0,0), tz.utc_to_local(DateTime.new(2004,4,4,7,0,0)))
|
15
|
-
assert_equal(DateTime.new(2004,10,31,1,59,59), tz.utc_to_local(DateTime.new(2004,10,31,5,59,59)))
|
16
|
-
assert_equal(DateTime.new(2004,10,31,1,0,0), tz.utc_to_local(DateTime.new(2004,10,31,6,0,0)))
|
17
|
-
|
18
|
-
assert_equal(DateTime.new(2004,4,4,6,59,59), tz.local_to_utc(DateTime.new(2004,4,4,1,59,59)))
|
19
|
-
assert_equal(DateTime.new(2004,4,4,7,0,0), tz.local_to_utc(DateTime.new(2004,4,4,3,0,0)))
|
20
|
-
assert_equal(DateTime.new(2004,10,31,5,59,59), tz.local_to_utc(DateTime.new(2004,10,31,1,59,59), true))
|
21
|
-
assert_equal(DateTime.new(2004,10,31,6,59,59), tz.local_to_utc(DateTime.new(2004,10,31,1,59,59), false))
|
22
|
-
assert_equal(DateTime.new(2004,10,31,5,0,0), tz.local_to_utc(DateTime.new(2004,10,31,1,0,0), true))
|
23
|
-
assert_equal(DateTime.new(2004,10,31,6,0,0), tz.local_to_utc(DateTime.new(2004,10,31,1,0,0), false))
|
24
|
-
|
25
|
-
assert_raises(PeriodNotFound) { tz.local_to_utc(DateTime.new(2004,4,4,2,0,0)) }
|
26
|
-
assert_raises(AmbiguousTime) { tz.local_to_utc(DateTime.new(2004,10,31,1,0,0)) }
|
27
|
-
|
28
|
-
assert_equal(:EST, tz.period_for_utc(DateTime.new(2004,4,4,6,59,59)).zone_identifier)
|
29
|
-
assert_equal(:EDT, tz.period_for_utc(DateTime.new(2004,4,4,7,0,0)).zone_identifier)
|
30
|
-
assert_equal(:EDT, tz.period_for_utc(DateTime.new(2004,10,31,5,59,59)).zone_identifier)
|
31
|
-
assert_equal(:EST, tz.period_for_utc(DateTime.new(2004,10,31,6,0,0)).zone_identifier)
|
32
|
-
|
33
|
-
assert_equal(:EST, tz.period_for_local(DateTime.new(2004,4,4,1,59,59)).zone_identifier)
|
34
|
-
assert_equal(:EDT, tz.period_for_local(DateTime.new(2004,4,4,3,0,0)).zone_identifier)
|
35
|
-
assert_equal(:EDT, tz.period_for_local(DateTime.new(2004,10,31,1,59,59), true).zone_identifier)
|
36
|
-
assert_equal(:EST, tz.period_for_local(DateTime.new(2004,10,31,1,59,59), false).zone_identifier)
|
37
|
-
assert_equal(:EDT, tz.period_for_local(DateTime.new(2004,10,31,1,0,0), true).zone_identifier)
|
38
|
-
assert_equal(:EST, tz.period_for_local(DateTime.new(2004,10,31,1,0,0), false).zone_identifier)
|
39
|
-
|
40
|
-
assert_equal(-18000, tz.period_for_utc(DateTime.new(2004,4,4,6,59,59)).utc_total_offset)
|
41
|
-
assert_equal(-14400, tz.period_for_utc(DateTime.new(2004,4,4,7,0,0)).utc_total_offset)
|
42
|
-
assert_equal(-14400, tz.period_for_utc(DateTime.new(2004,10,31,5,59,59)).utc_total_offset)
|
43
|
-
assert_equal(-18000, tz.period_for_utc(DateTime.new(2004,10,31,6,0,0)).utc_total_offset)
|
44
|
-
|
45
|
-
assert_equal(-18000, tz.period_for_local(DateTime.new(2004,4,4,1,59,59)).utc_total_offset)
|
46
|
-
assert_equal(-14400, tz.period_for_local(DateTime.new(2004,4,4,3,0,0)).utc_total_offset)
|
47
|
-
assert_equal(-14400, tz.period_for_local(DateTime.new(2004,10,31,1,59,59), true).utc_total_offset)
|
48
|
-
assert_equal(-18000, tz.period_for_local(DateTime.new(2004,10,31,1,59,59), false).utc_total_offset)
|
49
|
-
assert_equal(-14400, tz.period_for_local(DateTime.new(2004,10,31,1,0,0), true).utc_total_offset)
|
50
|
-
assert_equal(-18000, tz.period_for_local(DateTime.new(2004,10,31,1,0,0), false).utc_total_offset)
|
51
|
-
|
52
|
-
transitions = tz.transitions_up_to(DateTime.new(2005,1,1,0,0,0), DateTime.new(2004,1,1,0,0,0))
|
53
|
-
assert_equal(2, transitions.length)
|
54
|
-
assert_equal(TimeOrDateTime.new(DateTime.new(2004,4,4,7,0,0)), transitions[0].at)
|
55
|
-
assert_equal(TimezoneOffset.new(-18000, 0, :EST), transitions[0].previous_offset)
|
56
|
-
assert_equal(TimezoneOffset.new(-18000, 3600, :EDT), transitions[0].offset)
|
57
|
-
assert_equal(TimeOrDateTime.new(DateTime.new(2004,10,31,6,0,0)), transitions[1].at)
|
58
|
-
assert_equal(TimezoneOffset.new(-18000, 3600, :EDT), transitions[1].previous_offset)
|
59
|
-
assert_equal(TimezoneOffset.new(-18000, 0, :EST), transitions[1].offset)
|
60
|
-
|
61
|
-
offsets = tz.offsets_up_to(DateTime.new(2005,1,1,0,0,0), DateTime.new(2004,1,1,0,0,0))
|
62
|
-
assert_array_same_items([TimezoneOffset.new(-18000, 0, :EST), TimezoneOffset.new(-18000, 3600, :EDT)], offsets)
|
63
|
-
end
|
64
|
-
|
65
|
-
def test_1957
|
66
|
-
# This test cannot be run when using ZoneinfoDataSource on platforms
|
67
|
-
# that don't support Times before the epoch (i.e. Ruby < 1.9 on Windows)
|
68
|
-
# because it relates to the year 1957.
|
69
|
-
|
70
|
-
if !DataSource.get.kind_of?(ZoneinfoDataSource) || RubyCoreSupport.time_supports_negative
|
71
|
-
#America/New_York Sun Apr 28 06:59:59 1957 UTC = Sun Apr 28 01:59:59 1957 EST isdst=0 gmtoff=-18000
|
72
|
-
#America/New_York Sun Apr 28 07:00:00 1957 UTC = Sun Apr 28 03:00:00 1957 EDT isdst=1 gmtoff=-14400
|
73
|
-
#America/New_York Sun Oct 27 05:59:59 1957 UTC = Sun Oct 27 01:59:59 1957 EDT isdst=1 gmtoff=-14400
|
74
|
-
#America/New_York Sun Oct 27 06:00:00 1957 UTC = Sun Oct 27 01:00:00 1957 EST isdst=0 gmtoff=-18000
|
75
|
-
|
76
|
-
tz = Timezone.get('America/New_York')
|
77
|
-
assert_equal(DateTime.new(1957,4,28,1,59,59), tz.utc_to_local(DateTime.new(1957,4,28,6,59,59)))
|
78
|
-
assert_equal(DateTime.new(1957,4,28,3,0,0), tz.utc_to_local(DateTime.new(1957,4,28,7,0,0)))
|
79
|
-
assert_equal(DateTime.new(1957,10,27,1,59,59), tz.utc_to_local(DateTime.new(1957,10,27,5,59,59)))
|
80
|
-
assert_equal(DateTime.new(1957,10,27,1,0,0), tz.utc_to_local(DateTime.new(1957,10,27,6,0,0)))
|
81
|
-
|
82
|
-
assert_equal(DateTime.new(1957,4,28,6,59,59), tz.local_to_utc(DateTime.new(1957,4,28,1,59,59)))
|
83
|
-
assert_equal(DateTime.new(1957,4,28,7,0,0), tz.local_to_utc(DateTime.new(1957,4,28,3,0,0)))
|
84
|
-
assert_equal(DateTime.new(1957,10,27,5,59,59), tz.local_to_utc(DateTime.new(1957,10,27,1,59,59), true))
|
85
|
-
assert_equal(DateTime.new(1957,10,27,6,59,59), tz.local_to_utc(DateTime.new(1957,10,27,1,59,59), false))
|
86
|
-
assert_equal(DateTime.new(1957,10,27,5,0,0), tz.local_to_utc(DateTime.new(1957,10,27,1,0,0), true))
|
87
|
-
assert_equal(DateTime.new(1957,10,27,6,0,0), tz.local_to_utc(DateTime.new(1957,10,27,1,0,0), false))
|
88
|
-
|
89
|
-
assert_raises(PeriodNotFound) { tz.local_to_utc(DateTime.new(1957,4,28,2,0,0)) }
|
90
|
-
assert_raises(AmbiguousTime) { tz.local_to_utc(DateTime.new(1957,10,27,1,0,0)) }
|
91
|
-
|
92
|
-
assert_equal(:EST, tz.period_for_utc(DateTime.new(1957,4,28,6,59,59)).zone_identifier)
|
93
|
-
assert_equal(:EDT, tz.period_for_utc(DateTime.new(1957,4,28,7,0,0)).zone_identifier)
|
94
|
-
assert_equal(:EDT, tz.period_for_utc(DateTime.new(1957,10,27,5,59,59)).zone_identifier)
|
95
|
-
assert_equal(:EST, tz.period_for_utc(DateTime.new(1957,10,27,6,0,0)).zone_identifier)
|
96
|
-
|
97
|
-
assert_equal(:EST, tz.period_for_local(DateTime.new(1957,4,28,1,59,59)).zone_identifier)
|
98
|
-
assert_equal(:EDT, tz.period_for_local(DateTime.new(1957,4,28,3,0,0)).zone_identifier)
|
99
|
-
assert_equal(:EDT, tz.period_for_local(DateTime.new(1957,10,27,1,59,59), true).zone_identifier)
|
100
|
-
assert_equal(:EST, tz.period_for_local(DateTime.new(1957,10,27,1,59,59), false).zone_identifier)
|
101
|
-
assert_equal(:EDT, tz.period_for_local(DateTime.new(1957,10,27,1,0,0), true).zone_identifier)
|
102
|
-
assert_equal(:EST, tz.period_for_local(DateTime.new(1957,10,27,1,0,0), false).zone_identifier)
|
103
|
-
|
104
|
-
assert_equal(-18000, tz.period_for_utc(DateTime.new(1957,4,28,6,59,59)).utc_total_offset)
|
105
|
-
assert_equal(-14400, tz.period_for_utc(DateTime.new(1957,4,28,7,0,0)).utc_total_offset)
|
106
|
-
assert_equal(-14400, tz.period_for_utc(DateTime.new(1957,10,27,5,59,59)).utc_total_offset)
|
107
|
-
assert_equal(-18000, tz.period_for_utc(DateTime.new(1957,10,27,6,0,0)).utc_total_offset)
|
108
|
-
|
109
|
-
assert_equal(-18000, tz.period_for_local(DateTime.new(1957,4,28,1,59,59)).utc_total_offset)
|
110
|
-
assert_equal(-14400, tz.period_for_local(DateTime.new(1957,4,28,3,0,0)).utc_total_offset)
|
111
|
-
assert_equal(-14400, tz.period_for_local(DateTime.new(1957,10,27,1,59,59), true).utc_total_offset)
|
112
|
-
assert_equal(-18000, tz.period_for_local(DateTime.new(1957,10,27,1,59,59), false).utc_total_offset)
|
113
|
-
assert_equal(-14400, tz.period_for_local(DateTime.new(1957,10,27,1,0,0), true).utc_total_offset)
|
114
|
-
assert_equal(-18000, tz.period_for_local(DateTime.new(1957,10,27,1,0,0), false).utc_total_offset)
|
115
|
-
|
116
|
-
transitions = tz.transitions_up_to(DateTime.new(1958,1,1,0,0,0), DateTime.new(1957,1,1,0,0,0))
|
117
|
-
assert_equal(2, transitions.length)
|
118
|
-
assert_equal(TimeOrDateTime.new(DateTime.new(1957,4,28,7,0,0)), transitions[0].at)
|
119
|
-
assert_equal(TimezoneOffset.new(-18000, 0, :EST), transitions[0].previous_offset)
|
120
|
-
assert_equal(TimezoneOffset.new(-18000, 3600, :EDT), transitions[0].offset)
|
121
|
-
assert_equal(TimeOrDateTime.new(DateTime.new(1957,10,27,6,0,0)), transitions[1].at)
|
122
|
-
assert_equal(TimezoneOffset.new(-18000, 3600, :EDT), transitions[1].previous_offset)
|
123
|
-
assert_equal(TimezoneOffset.new(-18000, 0, :EST), transitions[1].offset)
|
124
|
-
|
125
|
-
offsets = tz.offsets_up_to(DateTime.new(1958,1,1,0,0,0), DateTime.new(1957,1,1,0,0,0))
|
126
|
-
assert_array_same_items([TimezoneOffset.new(-18000, 0, :EST), TimezoneOffset.new(-18000, 3600, :EDT)], offsets)
|
127
|
-
end
|
128
|
-
end
|
129
|
-
|
130
|
-
def test_time_boundary
|
131
|
-
#America/New_York Sun Oct 26 06:00:00 1969 UTC = Sun Oct 26 01:00:00 1969 EST isdst=0 gmtoff=-18000
|
132
|
-
#America/New_York Sun Apr 26 06:59:59 1970 UTC = Sun Apr 26 01:59:59 1970 EST isdst=0 gmtoff=-18000
|
133
|
-
|
134
|
-
tz = Timezone.get('America/New_York')
|
135
|
-
assert_equal(DateTime.new(1970,1,1,0,0,0), tz.utc_to_local(DateTime.new(1970,1,1,5,0,0)))
|
136
|
-
assert_equal(DateTime.new(1970,1,1,5,0,0), tz.local_to_utc(DateTime.new(1970,1,1,0,0,0)))
|
137
|
-
assert_equal(Time.utc(1970,1,1,0,0,0), tz.utc_to_local(Time.utc(1970,1,1,5,0,0)))
|
138
|
-
assert_equal(Time.utc(1970,1,1,5,0,0), tz.local_to_utc(Time.utc(1970,1,1,0,0,0)))
|
139
|
-
assert_equal(0, tz.utc_to_local(18000))
|
140
|
-
assert_equal(18000, tz.local_to_utc(0))
|
141
|
-
end
|
142
|
-
end
|
data/test/tc_timezone_offset.rb
DELETED
@@ -1,126 +0,0 @@
|
|
1
|
-
require File.join(File.expand_path(File.dirname(__FILE__)), 'test_utils')
|
2
|
-
|
3
|
-
include TZInfo
|
4
|
-
|
5
|
-
class TCTimezoneOffset < Minitest::Test
|
6
|
-
|
7
|
-
def test_utc_offset
|
8
|
-
o1 = TimezoneOffset.new(18000, 0, :TEST)
|
9
|
-
o2 = TimezoneOffset.new(-3600, 3600, :TEST2)
|
10
|
-
|
11
|
-
assert_equal(18000, o1.utc_offset)
|
12
|
-
assert_equal(-3600, o2.utc_offset)
|
13
|
-
end
|
14
|
-
|
15
|
-
def test_std_offset
|
16
|
-
o1 = TimezoneOffset.new(18000, 0, :TEST)
|
17
|
-
o2 = TimezoneOffset.new(-3600, 3600, :TEST2)
|
18
|
-
|
19
|
-
assert_equal(0, o1.std_offset)
|
20
|
-
assert_equal(3600, o2.std_offset)
|
21
|
-
end
|
22
|
-
|
23
|
-
def test_utc_total_offset
|
24
|
-
o1 = TimezoneOffset.new(18000, 0, :TEST)
|
25
|
-
o2 = TimezoneOffset.new(-3600, 3600, :TEST2)
|
26
|
-
|
27
|
-
assert_equal(18000, o1.utc_total_offset)
|
28
|
-
assert_equal(0, o2.utc_total_offset)
|
29
|
-
end
|
30
|
-
|
31
|
-
def test_abbreviation
|
32
|
-
o1 = TimezoneOffset.new(18000, 0, :TEST)
|
33
|
-
o2 = TimezoneOffset.new(-3600, 3600, :TEST2)
|
34
|
-
|
35
|
-
assert_equal(:TEST, o1.abbreviation)
|
36
|
-
assert_equal(:TEST2, o2.abbreviation)
|
37
|
-
end
|
38
|
-
|
39
|
-
def test_dst
|
40
|
-
o1 = TimezoneOffset.new(18000, 0, :TEST)
|
41
|
-
o2 = TimezoneOffset.new(-3600, 3600, :TEST2)
|
42
|
-
|
43
|
-
assert_equal(false, o1.dst?)
|
44
|
-
assert_equal(true, o2.dst?)
|
45
|
-
end
|
46
|
-
|
47
|
-
def test_to_local
|
48
|
-
o1 = TimezoneOffset.new(18000, 0, :TEST)
|
49
|
-
o2 = TimezoneOffset.new(-3600, 3600, :TEST2)
|
50
|
-
|
51
|
-
assert_equal(1148949080, o1.to_local(1148931080))
|
52
|
-
assert_equal(Time.utc(2006, 5, 30, 0, 31, 20), o1.to_local(Time.utc(2006, 5, 29, 19, 31, 20)))
|
53
|
-
assert_equal(Time.utc(2006, 5, 30, 0, 31, 20, 782000), o1.to_local(Time.utc(2006, 5, 29, 19, 31, 20, 782000)))
|
54
|
-
assert_equal(DateTime.new(2006, 5, 30, 0, 31, 20), o1.to_local(DateTime.new(2006, 5, 29, 19, 31, 20)))
|
55
|
-
assert_equal(DateTime.new(2006, 5, 30, 0, 31, 20 + Rational(782, 1000)), o1.to_local(DateTime.new(2006, 5, 29, 19, 31, 20 + Rational(782, 1000))))
|
56
|
-
assert_equal(1148949080, o1.to_local(1148931080))
|
57
|
-
assert(TimeOrDateTime.new(1148949080).eql?(o1.to_local(TimeOrDateTime.new(1148931080))))
|
58
|
-
|
59
|
-
assert_equal(1148931080, o2.to_local(1148931080))
|
60
|
-
assert_equal(Time.utc(2006, 5, 29, 19, 31, 20), o2.to_local(Time.utc(2006, 5, 29, 19, 31, 20)))
|
61
|
-
assert_equal(Time.utc(2006, 5, 29, 19, 31, 20, 123000), o2.to_local(Time.utc(2006, 5, 29, 19, 31, 20, 123000)))
|
62
|
-
assert_equal(DateTime.new(2006, 5, 29, 19, 31, 20), o2.to_local(DateTime.new(2006, 5, 29, 19, 31, 20)))
|
63
|
-
assert_equal(DateTime.new(2006, 5, 29, 19, 31, 20 + Rational(123, 1000)), o2.to_local(DateTime.new(2006, 5, 29, 19, 31, 20 + Rational(123, 1000))))
|
64
|
-
assert_equal(1148931080, o2.to_local(1148931080))
|
65
|
-
assert(TimeOrDateTime.new(1148931080).eql?(o2.to_local(TimeOrDateTime.new(1148931080))))
|
66
|
-
end
|
67
|
-
|
68
|
-
def test_to_utc
|
69
|
-
o1 = TimezoneOffset.new(18000, 0, :TEST)
|
70
|
-
o2 = TimezoneOffset.new(-3600, 3600, :TEST2)
|
71
|
-
|
72
|
-
assert_equal(1148913080, o1.to_utc(1148931080))
|
73
|
-
assert_equal(Time.utc(2006, 5, 29, 14, 31, 20), o1.to_utc(Time.utc(2006, 5, 29, 19, 31, 20)))
|
74
|
-
assert_equal(Time.utc(2006, 5, 29, 14, 31, 20, 913000), o1.to_utc(Time.utc(2006, 5, 29, 19, 31, 20, 913000)))
|
75
|
-
assert_equal(DateTime.new(2006, 5, 29, 14, 31, 20), o1.to_utc(DateTime.new(2006, 5, 29, 19, 31, 20)))
|
76
|
-
assert_equal(DateTime.new(2006, 5, 29, 14, 31, 20 + Rational(913,1000)), o1.to_utc(DateTime.new(2006, 5, 29, 19, 31, 20 + Rational(913,1000))))
|
77
|
-
assert_equal(1148913080, o1.to_utc(1148931080))
|
78
|
-
assert(TimeOrDateTime.new(1148913080).eql?(o1.to_utc(TimeOrDateTime.new(1148931080))))
|
79
|
-
|
80
|
-
assert_equal(1148931080, o2.to_local(1148931080))
|
81
|
-
assert_equal(Time.utc(2006, 5, 29, 19, 31, 20), o2.to_local(Time.utc(2006, 5, 29, 19, 31, 20)))
|
82
|
-
assert_equal(Time.utc(2006, 5, 29, 19, 31, 20, 323000), o2.to_local(Time.utc(2006, 5, 29, 19, 31, 20, 323000)))
|
83
|
-
assert_equal(DateTime.new(2006, 5, 29, 19, 31, 20), o2.to_local(DateTime.new(2006, 5, 29, 19, 31, 20)))
|
84
|
-
assert_equal(DateTime.new(2006, 5, 29, 19, 31, 20 + Rational(323, 1000)), o2.to_local(DateTime.new(2006, 5, 29, 19, 31, 20 + Rational(323, 1000))))
|
85
|
-
assert_equal(1148931080, o2.to_utc(1148931080))
|
86
|
-
assert(TimeOrDateTime.new(1148931080).eql?(o2.to_local(TimeOrDateTime.new(1148931080))))
|
87
|
-
end
|
88
|
-
|
89
|
-
def test_equality
|
90
|
-
o1 = TimezoneOffset.new(18000, 0, :TEST)
|
91
|
-
o2 = TimezoneOffset.new(18000, 0, :TEST)
|
92
|
-
o3 = TimezoneOffset.new(18001, 0, :TEST)
|
93
|
-
o4 = TimezoneOffset.new(18000, 1, :TEST)
|
94
|
-
o5 = TimezoneOffset.new(18000, 0, :TEST2)
|
95
|
-
|
96
|
-
assert_equal(true, o1 == o1)
|
97
|
-
assert_equal(true, o1 == o2)
|
98
|
-
assert_equal(false, o1 == o3)
|
99
|
-
assert_equal(false, o1 == o4)
|
100
|
-
assert_equal(false, o1 == o5)
|
101
|
-
assert_equal(false, o1 == Object.new)
|
102
|
-
end
|
103
|
-
|
104
|
-
def test_eql
|
105
|
-
o1 = TimezoneOffset.new(18000, 0, :TEST)
|
106
|
-
o2 = TimezoneOffset.new(18000, 0, :TEST)
|
107
|
-
o3 = TimezoneOffset.new(18001, 0, :TEST)
|
108
|
-
o4 = TimezoneOffset.new(18000, 1, :TEST)
|
109
|
-
o5 = TimezoneOffset.new(18000, 0, :TEST2)
|
110
|
-
|
111
|
-
assert_equal(true, o1.eql?(o1))
|
112
|
-
assert_equal(true, o1.eql?(o2))
|
113
|
-
assert_equal(false, o1.eql?(o3))
|
114
|
-
assert_equal(false, o1.eql?(o4))
|
115
|
-
assert_equal(false, o1.eql?(o5))
|
116
|
-
assert_equal(false, o1.eql?(Object.new))
|
117
|
-
end
|
118
|
-
|
119
|
-
def test_hash
|
120
|
-
o1 = TimezoneOffset.new(18000, 0, :TEST)
|
121
|
-
o2 = TimezoneOffset.new(-3600, 3600, :TEST2)
|
122
|
-
|
123
|
-
assert_equal(18000.hash ^ 0.hash ^ :TEST.hash, o1.hash)
|
124
|
-
assert_equal(-3600.hash ^ 3600.hash ^ :TEST2.hash, o2.hash)
|
125
|
-
end
|
126
|
-
end
|
data/test/tc_timezone_period.rb
DELETED
@@ -1,555 +0,0 @@
|
|
1
|
-
require File.join(File.expand_path(File.dirname(__FILE__)), 'test_utils')
|
2
|
-
|
3
|
-
include TZInfo
|
4
|
-
|
5
|
-
class TCTimezonePeriod < Minitest::Test
|
6
|
-
|
7
|
-
class TestTimezoneTransition < TimezoneTransition
|
8
|
-
def initialize(offset, previous_offset, at)
|
9
|
-
super(offset, previous_offset)
|
10
|
-
@at = TimeOrDateTime.wrap(at)
|
11
|
-
end
|
12
|
-
|
13
|
-
def at
|
14
|
-
@at
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
def test_initialize_start_end
|
19
|
-
std = TimezoneOffset.new(-7200, 0, :TEST)
|
20
|
-
dst = TimezoneOffset.new(-7200, 3600, :TEST)
|
21
|
-
start_t = TestTimezoneTransition.new(dst, std, 1136073600)
|
22
|
-
end_t = TestTimezoneTransition.new(std, dst, 1136160000)
|
23
|
-
|
24
|
-
p = TimezonePeriod.new(start_t, end_t)
|
25
|
-
|
26
|
-
assert_same(start_t, p.start_transition)
|
27
|
-
assert_same(end_t, p.end_transition)
|
28
|
-
assert_same(dst, p.offset)
|
29
|
-
assert_equal(DateTime.new(2006,1,1,0,0,0), p.utc_start)
|
30
|
-
assert_equal(Time.utc(2006,1,1,0,0,0), p.utc_start_time)
|
31
|
-
assert_equal(DateTime.new(2006,1,2,0,0,0), p.utc_end)
|
32
|
-
assert_equal(Time.utc(2006,1,2,0,0,0), p.utc_end_time)
|
33
|
-
assert_equal(-7200, p.utc_offset)
|
34
|
-
assert_equal(3600, p.std_offset)
|
35
|
-
assert_equal(-3600, p.utc_total_offset)
|
36
|
-
assert_equal(Rational(-3600, 86400), p.utc_total_offset_rational)
|
37
|
-
assert_equal(:TEST, p.zone_identifier)
|
38
|
-
assert_equal(:TEST, p.abbreviation)
|
39
|
-
assert_equal(DateTime.new(2005,12,31,23,0,0), p.local_start)
|
40
|
-
assert_equal(Time.utc(2005,12,31,23,0,0), p.local_start_time)
|
41
|
-
assert_equal(DateTime.new(2006,1,1,23,0,0), p.local_end)
|
42
|
-
assert_equal(Time.utc(2006,1,1,23,0,0), p.local_end_time)
|
43
|
-
end
|
44
|
-
|
45
|
-
def test_initialize_start_end_offset
|
46
|
-
std = TimezoneOffset.new(-7200, 0, :TEST)
|
47
|
-
dst = TimezoneOffset.new(-7200, 3600, :TEST)
|
48
|
-
special = TimezoneOffset.new(0, 0, :SPECIAL)
|
49
|
-
start_t = TestTimezoneTransition.new(dst, std, 1136073600)
|
50
|
-
end_t = TestTimezoneTransition.new(std, dst, 1136160000)
|
51
|
-
|
52
|
-
assert_raises(ArgumentError) { TimezonePeriod.new(start_t, end_t, special) }
|
53
|
-
end
|
54
|
-
|
55
|
-
def test_initialize_start
|
56
|
-
std = TimezoneOffset.new(-7200, 0, :TEST)
|
57
|
-
dst = TimezoneOffset.new(-7200, 3600, :TEST)
|
58
|
-
start_t = TestTimezoneTransition.new(dst, std, 1136073600)
|
59
|
-
|
60
|
-
p = TimezonePeriod.new(start_t, nil)
|
61
|
-
|
62
|
-
assert_same(start_t, p.start_transition)
|
63
|
-
assert_nil(p.end_transition)
|
64
|
-
assert_same(dst, p.offset)
|
65
|
-
assert_equal(DateTime.new(2006,1,1,0,0,0), p.utc_start)
|
66
|
-
assert_equal(Time.utc(2006,1,1,0,0,0), p.utc_start_time)
|
67
|
-
assert_nil(p.utc_end)
|
68
|
-
assert_nil(p.utc_end_time)
|
69
|
-
assert_equal(-7200, p.utc_offset)
|
70
|
-
assert_equal(3600, p.std_offset)
|
71
|
-
assert_equal(-3600, p.utc_total_offset)
|
72
|
-
assert_equal(Rational(-3600, 86400), p.utc_total_offset_rational)
|
73
|
-
assert_equal(:TEST, p.zone_identifier)
|
74
|
-
assert_equal(:TEST, p.abbreviation)
|
75
|
-
assert_equal(DateTime.new(2005,12,31,23,0,0), p.local_start)
|
76
|
-
assert_equal(Time.utc(2005,12,31,23,0,0), p.local_start_time)
|
77
|
-
assert_nil(p.local_end)
|
78
|
-
assert_nil(p.local_end_time)
|
79
|
-
end
|
80
|
-
|
81
|
-
def test_initialize_start_offset
|
82
|
-
std = TimezoneOffset.new(-7200, 0, :TEST)
|
83
|
-
dst = TimezoneOffset.new(-7200, 3600, :TEST)
|
84
|
-
special = TimezoneOffset.new(0, 0, :SPECIAL)
|
85
|
-
start_t = TestTimezoneTransition.new(dst, std, 1136073600)
|
86
|
-
|
87
|
-
assert_raises(ArgumentError) { TimezonePeriod.new(start_t, nil, special) }
|
88
|
-
end
|
89
|
-
|
90
|
-
def test_initialize_end
|
91
|
-
std = TimezoneOffset.new(-7200, 0, :TEST)
|
92
|
-
dst = TimezoneOffset.new(-7200, 3600, :TEST)
|
93
|
-
end_t = TestTimezoneTransition.new(std, dst, 1136160000)
|
94
|
-
|
95
|
-
p = TimezonePeriod.new(nil, end_t)
|
96
|
-
|
97
|
-
assert_nil(p.start_transition)
|
98
|
-
assert_same(end_t, p.end_transition)
|
99
|
-
assert_same(dst, p.offset)
|
100
|
-
assert_nil(p.utc_start)
|
101
|
-
assert_nil(p.utc_start_time)
|
102
|
-
assert_equal(DateTime.new(2006,1,2,0,0,0), p.utc_end)
|
103
|
-
assert_equal(Time.utc(2006,1,2,0,0,0), p.utc_end_time)
|
104
|
-
assert_equal(-7200, p.utc_offset)
|
105
|
-
assert_equal(3600, p.std_offset)
|
106
|
-
assert_equal(-3600, p.utc_total_offset)
|
107
|
-
assert_equal(Rational(-3600, 86400), p.utc_total_offset_rational)
|
108
|
-
assert_equal(:TEST, p.zone_identifier)
|
109
|
-
assert_equal(:TEST, p.abbreviation)
|
110
|
-
assert_nil(p.local_start)
|
111
|
-
assert_nil(p.local_start_time)
|
112
|
-
assert_equal(DateTime.new(2006,1,1,23,0,0), p.local_end)
|
113
|
-
assert_equal(Time.utc(2006,1,1,23,0,0), p.local_end_time)
|
114
|
-
end
|
115
|
-
|
116
|
-
def test_initialize_end_offset
|
117
|
-
std = TimezoneOffset.new(-7200, 0, :TEST)
|
118
|
-
dst = TimezoneOffset.new(-7200, 3600, :TEST)
|
119
|
-
special = TimezoneOffset.new(0, 0, :SPECIAL)
|
120
|
-
end_t = TestTimezoneTransition.new(std, dst, 1136160000)
|
121
|
-
|
122
|
-
assert_raises(ArgumentError) { TimezonePeriod.new(nil, end_t, special) }
|
123
|
-
end
|
124
|
-
|
125
|
-
def test_initialize
|
126
|
-
assert_raises(ArgumentError) { TimezonePeriod.new(nil, nil) }
|
127
|
-
end
|
128
|
-
|
129
|
-
def test_initialize_offset
|
130
|
-
special = TimezoneOffset.new(0, 0, :SPECIAL)
|
131
|
-
|
132
|
-
p = TimezonePeriod.new(nil, nil, special)
|
133
|
-
|
134
|
-
assert_nil(p.start_transition)
|
135
|
-
assert_nil(p.end_transition)
|
136
|
-
assert_same(special, p.offset)
|
137
|
-
assert_nil(p.utc_start)
|
138
|
-
assert_nil(p.utc_start_time)
|
139
|
-
assert_nil(p.utc_end)
|
140
|
-
assert_nil(p.utc_end_time)
|
141
|
-
assert_equal(0, p.utc_offset)
|
142
|
-
assert_equal(0, p.std_offset)
|
143
|
-
assert_equal(0, p.utc_total_offset)
|
144
|
-
assert_equal(Rational(0, 86400), p.utc_total_offset_rational)
|
145
|
-
assert_equal(:SPECIAL, p.zone_identifier)
|
146
|
-
assert_equal(:SPECIAL, p.abbreviation)
|
147
|
-
assert_nil(p.local_start)
|
148
|
-
assert_nil(p.local_start_time)
|
149
|
-
assert_nil(p.local_end)
|
150
|
-
assert_nil(p.local_end_time)
|
151
|
-
end
|
152
|
-
|
153
|
-
def test_utc_total_offset_rational_after_freeze
|
154
|
-
o = TimezoneOffset.new(3600, 0, :TEST)
|
155
|
-
p = TimezonePeriod.new(nil, nil, o)
|
156
|
-
p.freeze
|
157
|
-
assert_equal(Rational(1, 24), p.utc_total_offset_rational)
|
158
|
-
end
|
159
|
-
|
160
|
-
def test_dst
|
161
|
-
p1 = TimezonePeriod.new(nil, nil, TimezoneOffset.new(-14400, 3600, :TEST))
|
162
|
-
p2 = TimezonePeriod.new(nil, nil, TimezoneOffset.new(-14400, 0, :TEST))
|
163
|
-
p3 = TimezonePeriod.new(nil, nil, TimezoneOffset.new(-14400, -3600, :TEST))
|
164
|
-
p4 = TimezonePeriod.new(nil, nil, TimezoneOffset.new(-14400, 7200, :TEST))
|
165
|
-
p5 = TimezonePeriod.new(nil, nil, TimezoneOffset.new(-14400, -7200, :TEST))
|
166
|
-
|
167
|
-
assert_equal(true, p1.dst?)
|
168
|
-
assert_equal(false, p2.dst?)
|
169
|
-
assert_equal(true, p3.dst?)
|
170
|
-
assert_equal(true, p4.dst?)
|
171
|
-
assert_equal(true, p5.dst?)
|
172
|
-
end
|
173
|
-
|
174
|
-
def test_valid_for_utc
|
175
|
-
offset = TimezoneOffset.new(-7200, 3600, :TEST)
|
176
|
-
t1 = TestTimezoneTransition.new(offset, offset, 1104541261)
|
177
|
-
t2 = TestTimezoneTransition.new(offset, offset, 1107309722)
|
178
|
-
t3 = TestTimezoneTransition.new(offset, offset, DateTime.new(1960, 1, 1, 1, 1, 1))
|
179
|
-
t4 = TestTimezoneTransition.new(offset, offset, DateTime.new(1960, 2, 2, 2, 2, 2))
|
180
|
-
|
181
|
-
p1 = TimezonePeriod.new(t1, t2)
|
182
|
-
p2 = TimezonePeriod.new(nil, t2)
|
183
|
-
p3 = TimezonePeriod.new(t1, nil)
|
184
|
-
p4 = TimezonePeriod.new(nil, nil, offset)
|
185
|
-
p5 = TimezonePeriod.new(t3, t4)
|
186
|
-
|
187
|
-
assert_equal(true, p1.valid_for_utc?(DateTime.new(2005,1,1,1,1,1)))
|
188
|
-
assert_equal(true, p1.valid_for_utc?(Time.utc(2005,2,2,2,2,1)))
|
189
|
-
assert_equal(true, p1.valid_for_utc?(1104541262))
|
190
|
-
assert_equal(true, p1.valid_for_utc?(DateTime.new(2005,2,2,2,2,0)))
|
191
|
-
assert_equal(false, p1.valid_for_utc?(DateTime.new(2005,1,1,1,1,0)))
|
192
|
-
assert_equal(false, p1.valid_for_utc?(DateTime.new(2005,2,2,2,2,3)))
|
193
|
-
assert_equal(false, p1.valid_for_utc?(DateTime.new(1960,1,1,1,1,0)))
|
194
|
-
assert_equal(false, p1.valid_for_utc?(DateTime.new(2040,1,1,1,1,0)))
|
195
|
-
|
196
|
-
assert_equal(true, p2.valid_for_utc?(DateTime.new(2005,1,1,1,1,1)))
|
197
|
-
assert_equal(true, p2.valid_for_utc?(Time.utc(2005,2,2,2,2,1)))
|
198
|
-
assert_equal(true, p2.valid_for_utc?(1104541262))
|
199
|
-
assert_equal(true, p2.valid_for_utc?(DateTime.new(2005,2,2,2,2,0)))
|
200
|
-
assert_equal(true, p2.valid_for_utc?(DateTime.new(2005,1,1,1,1,0)))
|
201
|
-
assert_equal(false, p2.valid_for_utc?(DateTime.new(2005,2,2,2,2,3)))
|
202
|
-
assert_equal(true, p2.valid_for_utc?(DateTime.new(1960,1,1,1,1,0)))
|
203
|
-
assert_equal(false, p2.valid_for_utc?(DateTime.new(2040,1,1,1,1,0)))
|
204
|
-
|
205
|
-
assert_equal(true, p3.valid_for_utc?(DateTime.new(2005,1,1,1,1,1)))
|
206
|
-
assert_equal(true, p3.valid_for_utc?(Time.utc(2005,2,2,2,2,1)))
|
207
|
-
assert_equal(true, p3.valid_for_utc?(1104541262))
|
208
|
-
assert_equal(true, p3.valid_for_utc?(DateTime.new(2005,2,2,2,2,0)))
|
209
|
-
assert_equal(false, p3.valid_for_utc?(DateTime.new(2005,1,1,1,1,0)))
|
210
|
-
assert_equal(true, p3.valid_for_utc?(DateTime.new(2005,2,2,2,2,3)))
|
211
|
-
assert_equal(false, p3.valid_for_utc?(DateTime.new(1960,1,1,1,1,0)))
|
212
|
-
assert_equal(true, p3.valid_for_utc?(DateTime.new(2040,1,1,1,1,0)))
|
213
|
-
|
214
|
-
assert_equal(true, p4.valid_for_utc?(DateTime.new(2005,1,1,1,1,1)))
|
215
|
-
assert_equal(true, p4.valid_for_utc?(Time.utc(2005,2,2,2,2,1)))
|
216
|
-
assert_equal(true, p4.valid_for_utc?(1104541262))
|
217
|
-
assert_equal(true, p4.valid_for_utc?(DateTime.new(2005,2,2,2,2,0)))
|
218
|
-
assert_equal(true, p4.valid_for_utc?(DateTime.new(2005,1,1,1,1,0)))
|
219
|
-
assert_equal(true, p4.valid_for_utc?(DateTime.new(2005,2,2,2,2,3)))
|
220
|
-
assert_equal(true, p4.valid_for_utc?(DateTime.new(1960,1,1,1,1,0)))
|
221
|
-
assert_equal(true, p4.valid_for_utc?(DateTime.new(2040,1,1,1,1,0)))
|
222
|
-
|
223
|
-
assert_equal(false, p5.valid_for_utc?(Time.utc(2005,1,1,1,1,1)))
|
224
|
-
assert_equal(false, p5.valid_for_utc?(1104541262))
|
225
|
-
end
|
226
|
-
|
227
|
-
def test_utc_after_start
|
228
|
-
offset = TimezoneOffset.new(-7200, 3600, :TEST)
|
229
|
-
t1 = TestTimezoneTransition.new(offset, offset, 1104541261)
|
230
|
-
t2 = TestTimezoneTransition.new(offset, offset, 1107309722)
|
231
|
-
t3 = TestTimezoneTransition.new(offset, offset, DateTime.new(1945, 1, 1, 1, 1, 1))
|
232
|
-
t4 = TestTimezoneTransition.new(offset, offset, DateTime.new(1945, 2, 2, 2, 2, 2))
|
233
|
-
|
234
|
-
p1 = TimezonePeriod.new(t1, t2)
|
235
|
-
p2 = TimezonePeriod.new(nil, t2)
|
236
|
-
p3 = TimezonePeriod.new(t3, t4)
|
237
|
-
|
238
|
-
assert_equal(true, p1.utc_after_start?(DateTime.new(2005,1,1,1,1,1)))
|
239
|
-
assert_equal(true, p1.utc_after_start?(Time.utc(2005,1,1,1,1,2)))
|
240
|
-
assert_equal(false, p1.utc_after_start?(1104541260))
|
241
|
-
assert_equal(true, p1.utc_after_start?(DateTime.new(2045,1,1,1,1,0)))
|
242
|
-
assert_equal(false, p1.utc_after_start?(DateTime.new(1955,1,1,1,1,0)))
|
243
|
-
|
244
|
-
assert_equal(true, p2.utc_after_start?(DateTime.new(2005,1,1,1,1,1)))
|
245
|
-
assert_equal(true, p2.utc_after_start?(Time.utc(2005,1,1,1,1,2)))
|
246
|
-
assert_equal(true, p2.utc_after_start?(1104541260))
|
247
|
-
|
248
|
-
assert_equal(true, p3.utc_after_start?(Time.utc(2005,1,2,1,1,1)))
|
249
|
-
assert_equal(true, p3.utc_after_start?(1104627661))
|
250
|
-
end
|
251
|
-
|
252
|
-
def test_utc_before_end
|
253
|
-
offset = TimezoneOffset.new(-7200, 3600, :TEST)
|
254
|
-
t1 = TestTimezoneTransition.new(offset, offset, 1104541261)
|
255
|
-
t2 = TestTimezoneTransition.new(offset, offset, 1107309722)
|
256
|
-
t3 = TestTimezoneTransition.new(offset, offset, DateTime.new(1945, 1, 1, 1, 1, 1))
|
257
|
-
t4 = TestTimezoneTransition.new(offset, offset, DateTime.new(1945, 2, 2, 2, 2, 2))
|
258
|
-
|
259
|
-
p1 = TimezonePeriod.new(t1, t2)
|
260
|
-
p2 = TimezonePeriod.new(t1, nil)
|
261
|
-
p3 = TimezonePeriod.new(t3, t4)
|
262
|
-
|
263
|
-
assert_equal(true, p1.utc_before_end?(DateTime.new(2005,2,2,2,2,1)))
|
264
|
-
assert_equal(true, p1.utc_before_end?(Time.utc(2005,2,2,2,2,0)))
|
265
|
-
assert_equal(false, p1.utc_before_end?(1107309723))
|
266
|
-
assert_equal(false, p1.utc_before_end?(DateTime.new(2045,1,1,1,1,0)))
|
267
|
-
assert_equal(true, p1.utc_before_end?(DateTime.new(1955,1,1,1,1,0)))
|
268
|
-
|
269
|
-
assert_equal(true, p2.utc_before_end?(DateTime.new(2005,2,2,2,2,1)))
|
270
|
-
assert_equal(true, p2.utc_before_end?(Time.utc(2005,2,2,2,2,0)))
|
271
|
-
assert_equal(true, p2.utc_before_end?(1107309723))
|
272
|
-
|
273
|
-
assert_equal(false, p3.utc_before_end?(Time.utc(2005,1,2,1,1,1)))
|
274
|
-
assert_equal(false, p3.utc_before_end?(1104627661))
|
275
|
-
end
|
276
|
-
|
277
|
-
def test_valid_for_local
|
278
|
-
offset = TimezoneOffset.new(-7200, 3600, :TEST)
|
279
|
-
t1 = TestTimezoneTransition.new(offset, offset, 1104544861)
|
280
|
-
t2 = TestTimezoneTransition.new(offset, offset, 1107313322)
|
281
|
-
t3 = TestTimezoneTransition.new(offset, offset, 1104544861)
|
282
|
-
t4 = TestTimezoneTransition.new(offset, offset, DateTime.new(1960, 1, 1, 1, 1, 1))
|
283
|
-
t5 = TestTimezoneTransition.new(offset, offset, DateTime.new(1960, 2, 2, 2, 2, 2))
|
284
|
-
|
285
|
-
p1 = TimezonePeriod.new(t1, t2)
|
286
|
-
p2 = TimezonePeriod.new(nil, t2)
|
287
|
-
p3 = TimezonePeriod.new(t3, nil)
|
288
|
-
p4 = TimezonePeriod.new(nil, nil, offset)
|
289
|
-
p5 = TimezonePeriod.new(t4, t5)
|
290
|
-
|
291
|
-
assert_equal(true, p1.valid_for_local?(DateTime.new(2005,1,1,1,1,1)))
|
292
|
-
assert_equal(true, p1.valid_for_local?(Time.utc(2005,2,2,2,2,1)))
|
293
|
-
assert_equal(true, p1.valid_for_local?(1104541262))
|
294
|
-
assert_equal(true, p1.valid_for_local?(DateTime.new(2005,2,2,2,2,0)))
|
295
|
-
assert_equal(false, p1.valid_for_local?(DateTime.new(2005,1,1,1,1,0)))
|
296
|
-
assert_equal(false, p1.valid_for_local?(DateTime.new(2005,2,2,2,2,3)))
|
297
|
-
assert_equal(false, p1.valid_for_local?(DateTime.new(1960,1,1,1,1,0)))
|
298
|
-
assert_equal(false, p1.valid_for_local?(DateTime.new(2040,1,1,1,1,0)))
|
299
|
-
|
300
|
-
assert_equal(true, p2.valid_for_local?(DateTime.new(2005,1,1,1,1,1)))
|
301
|
-
assert_equal(true, p2.valid_for_local?(DateTime.new(2005,2,2,2,2,1)))
|
302
|
-
assert_equal(true, p2.valid_for_local?(1104541262))
|
303
|
-
assert_equal(true, p2.valid_for_local?(DateTime.new(2005,2,2,2,2,0)))
|
304
|
-
assert_equal(true, p2.valid_for_local?(DateTime.new(2005,1,1,1,1,0)))
|
305
|
-
assert_equal(false, p2.valid_for_local?(DateTime.new(2005,2,2,2,2,3)))
|
306
|
-
assert_equal(true, p2.valid_for_local?(DateTime.new(1960,1,1,1,1,0)))
|
307
|
-
assert_equal(false, p2.valid_for_local?(DateTime.new(2040,1,1,1,1,0)))
|
308
|
-
|
309
|
-
assert_equal(true, p3.valid_for_local?(DateTime.new(2005,1,1,1,1,1)))
|
310
|
-
assert_equal(true, p3.valid_for_local?(DateTime.new(2005,2,2,2,2,1)))
|
311
|
-
assert_equal(true, p3.valid_for_local?(1104541262))
|
312
|
-
assert_equal(true, p3.valid_for_local?(DateTime.new(2005,2,2,2,2,0)))
|
313
|
-
assert_equal(false, p3.valid_for_local?(DateTime.new(2005,1,1,1,1,0)))
|
314
|
-
assert_equal(true, p3.valid_for_local?(DateTime.new(2005,2,2,2,2,3)))
|
315
|
-
assert_equal(false, p3.valid_for_local?(DateTime.new(1960,1,1,1,1,0)))
|
316
|
-
assert_equal(true, p3.valid_for_local?(DateTime.new(2040,1,1,1,1,0)))
|
317
|
-
|
318
|
-
assert_equal(true, p4.valid_for_local?(DateTime.new(2005,1,1,1,1,1)))
|
319
|
-
assert_equal(true, p4.valid_for_local?(DateTime.new(2005,2,2,2,2,1)))
|
320
|
-
assert_equal(true, p4.valid_for_local?(1104541262))
|
321
|
-
assert_equal(true, p4.valid_for_local?(DateTime.new(2005,2,2,2,2,0)))
|
322
|
-
assert_equal(true, p4.valid_for_local?(DateTime.new(2005,1,1,1,1,0)))
|
323
|
-
assert_equal(true, p4.valid_for_local?(DateTime.new(2005,2,2,2,2,3)))
|
324
|
-
assert_equal(true, p4.valid_for_local?(DateTime.new(1960,1,1,1,1,0)))
|
325
|
-
assert_equal(true, p4.valid_for_local?(DateTime.new(2040,1,1,1,1,0)))
|
326
|
-
|
327
|
-
assert_equal(false, p5.valid_for_utc?(Time.utc(2005,1,1,1,1,1)))
|
328
|
-
assert_equal(false, p5.valid_for_utc?(1104541262))
|
329
|
-
end
|
330
|
-
|
331
|
-
def test_local_after_start
|
332
|
-
offset = TimezoneOffset.new(-7200, 3600, :TEST)
|
333
|
-
t1 = TestTimezoneTransition.new(offset, offset, 1104544861)
|
334
|
-
t2 = TestTimezoneTransition.new(offset, offset, 1107313322)
|
335
|
-
t3 = TestTimezoneTransition.new(offset, offset, DateTime.new(1945, 1, 1, 1, 1, 1))
|
336
|
-
t4 = TestTimezoneTransition.new(offset, offset, DateTime.new(1945, 2, 2, 2, 2, 2))
|
337
|
-
|
338
|
-
p1 = TimezonePeriod.new(t1, t2)
|
339
|
-
p2 = TimezonePeriod.new(nil, t2)
|
340
|
-
p3 = TimezonePeriod.new(t3, t4)
|
341
|
-
|
342
|
-
assert_equal(true, p1.local_after_start?(DateTime.new(2005,1,1,1,1,1)))
|
343
|
-
assert_equal(true, p1.local_after_start?(Time.utc(2005,1,1,1,1,2)))
|
344
|
-
assert_equal(false, p1.local_after_start?(1104541260))
|
345
|
-
assert_equal(true, p1.local_after_start?(DateTime.new(2045,1,1,1,1,0)))
|
346
|
-
assert_equal(false, p1.local_after_start?(DateTime.new(1955,1,1,1,1,0)))
|
347
|
-
|
348
|
-
assert_equal(true, p2.local_after_start?(DateTime.new(2005,1,1,1,1,1)))
|
349
|
-
assert_equal(true, p2.local_after_start?(Time.utc(2005,1,1,1,1,2)))
|
350
|
-
assert_equal(true, p2.local_after_start?(1104541260))
|
351
|
-
|
352
|
-
assert_equal(true, p3.local_after_start?(Time.utc(2005,1,2,1,1,1)))
|
353
|
-
assert_equal(true, p3.local_after_start?(1104627661))
|
354
|
-
end
|
355
|
-
|
356
|
-
def test_local_before_end
|
357
|
-
offset = TimezoneOffset.new(-7200, 3600, :TEST)
|
358
|
-
t1 = TestTimezoneTransition.new(offset, offset, 1104544861)
|
359
|
-
t2 = TestTimezoneTransition.new(offset, offset, 1107313322)
|
360
|
-
t3 = TestTimezoneTransition.new(offset, offset, DateTime.new(1945, 1, 1, 1, 1, 1))
|
361
|
-
t4 = TestTimezoneTransition.new(offset, offset, DateTime.new(1945, 2, 2, 2, 2, 2))
|
362
|
-
|
363
|
-
p1 = TimezonePeriod.new(t1, t2)
|
364
|
-
p2 = TimezonePeriod.new(t1, nil)
|
365
|
-
p3 = TimezonePeriod.new(t3, t4)
|
366
|
-
|
367
|
-
assert_equal(true, p1.local_before_end?(DateTime.new(2005,2,2,2,2,1)))
|
368
|
-
assert_equal(true, p1.local_before_end?(Time.utc(2005,2,2,2,2,0)))
|
369
|
-
assert_equal(false, p1.local_before_end?(1107309723))
|
370
|
-
assert_equal(false, p1.local_before_end?(DateTime.new(2045,1,1,1,1,0)))
|
371
|
-
assert_equal(true, p1.local_before_end?(DateTime.new(1955,1,1,1,1,0)))
|
372
|
-
|
373
|
-
assert_equal(true, p2.local_before_end?(DateTime.new(2005,2,2,2,2,1)))
|
374
|
-
assert_equal(true, p2.local_before_end?(Time.utc(2005,2,2,2,2,0)))
|
375
|
-
assert_equal(true, p2.local_before_end?(1107309723))
|
376
|
-
|
377
|
-
assert_equal(false, p3.local_before_end?(Time.utc(2005,1,2,1,1,1)))
|
378
|
-
assert_equal(false, p3.local_before_end?(1104627661))
|
379
|
-
end
|
380
|
-
|
381
|
-
def test_to_local
|
382
|
-
p1 = TimezonePeriod.new(nil, nil, TimezoneOffset.new(-14400, 3600, :TEST))
|
383
|
-
p2 = TimezonePeriod.new(nil, nil, TimezoneOffset.new(-14400, 0, :TEST))
|
384
|
-
p3 = TimezonePeriod.new(nil, nil, TimezoneOffset.new(7200, 3600, :TEST))
|
385
|
-
|
386
|
-
assert_equal(DateTime.new(2005,1,19,22,0,0), p1.to_local(DateTime.new(2005,1,20,1,0,0)))
|
387
|
-
assert_equal(DateTime.new(2005,1,19,22,0,0 + Rational(512,1000)), p1.to_local(DateTime.new(2005,1,20,1,0,0 + Rational(512,1000))))
|
388
|
-
assert_equal(Time.utc(2005,1,19,21,0,0), p2.to_local(Time.utc(2005,1,20,1,0,0)))
|
389
|
-
assert_equal(Time.utc(2005,1,19,21,0,0,512000), p2.to_local(Time.utc(2005,1,20,1,0,0,512000)))
|
390
|
-
assert_equal(1106193600, p3.to_local(1106182800))
|
391
|
-
end
|
392
|
-
|
393
|
-
def test_to_utc
|
394
|
-
p1 = TimezonePeriod.new(nil, nil, TimezoneOffset.new(-14400, 3600, :TEST))
|
395
|
-
p2 = TimezonePeriod.new(nil, nil, TimezoneOffset.new(-14400, 0, :TEST))
|
396
|
-
p3 = TimezonePeriod.new(nil, nil, TimezoneOffset.new(7200, 3600, :TEST))
|
397
|
-
|
398
|
-
assert_equal(DateTime.new(2005,1,20,4,0,0), p1.to_utc(DateTime.new(2005,1,20,1,0,0)))
|
399
|
-
assert_equal(DateTime.new(2005,1,20,4,0,0 + Rational(571,1000)), p1.to_utc(DateTime.new(2005,1,20,1,0,0 + Rational(571,1000))))
|
400
|
-
assert_equal(Time.utc(2005,1,20,5,0,0), p2.to_utc(Time.utc(2005,1,20,1,0,0)))
|
401
|
-
assert_equal(Time.utc(2005,1,20,5,0,0,571000), p2.to_utc(Time.utc(2005,1,20,1,0,0,571000)))
|
402
|
-
assert_equal(1106172000, p3.to_utc(1106182800))
|
403
|
-
end
|
404
|
-
|
405
|
-
def test_time_boundary_start
|
406
|
-
o1 = TimezoneOffset.new(-3600, 0, :TEST)
|
407
|
-
o2 = TimezoneOffset.new(-3600, 3600, :TEST)
|
408
|
-
t1 = TestTimezoneTransition.new(o1, o2, 0)
|
409
|
-
|
410
|
-
p1 = TimezonePeriod.new(t1, nil)
|
411
|
-
|
412
|
-
assert_equal(DateTime.new(1969,12,31,23,0,0), p1.local_start)
|
413
|
-
|
414
|
-
# Conversion to Time will fail on systems that don't support negative times.
|
415
|
-
if RubyCoreSupport.time_supports_negative
|
416
|
-
assert_equal(Time.utc(1969,12,31,23,0,0), p1.local_start_time)
|
417
|
-
end
|
418
|
-
end
|
419
|
-
|
420
|
-
def test_time_boundary_end
|
421
|
-
o1 = TimezoneOffset.new(0, 3600, :TEST)
|
422
|
-
o2 = TimezoneOffset.new(0, 0, :TEST)
|
423
|
-
t1 = TestTimezoneTransition.new(o2, o1, 2147482800)
|
424
|
-
|
425
|
-
p1 = TimezonePeriod.new(nil, t1)
|
426
|
-
|
427
|
-
assert_equal(DateTime.new(2038,1,19,4,0,0), p1.local_end)
|
428
|
-
|
429
|
-
# Conversion to Time will fail on systems that don't support 64-bit times
|
430
|
-
if RubyCoreSupport.time_supports_64bit
|
431
|
-
assert_equal(Time.utc(2038,1,19,4,0,0), p1.local_end_time)
|
432
|
-
end
|
433
|
-
end
|
434
|
-
|
435
|
-
def test_equality
|
436
|
-
o1 = TimezoneOffset.new(0, 3600, :TEST)
|
437
|
-
o2 = TimezoneOffset.new(0, 0, :TEST)
|
438
|
-
t1 = TestTimezoneTransition.new(o1, o2, 1149368400)
|
439
|
-
t2 = TestTimezoneTransition.new(o1, o2, DateTime.new(2006, 6, 3, 21, 0, 0))
|
440
|
-
t3 = TestTimezoneTransition.new(o1, o2, 1149454800)
|
441
|
-
t4 = TestTimezoneTransition.new(o1, o2, 1149541200)
|
442
|
-
|
443
|
-
p1 = TimezonePeriod.new(t1, t3)
|
444
|
-
p2 = TimezonePeriod.new(t1, t3)
|
445
|
-
p3 = TimezonePeriod.new(t2, t3)
|
446
|
-
p4 = TimezonePeriod.new(t3, nil)
|
447
|
-
p5 = TimezonePeriod.new(t3, nil)
|
448
|
-
p6 = TimezonePeriod.new(t4, nil)
|
449
|
-
p7 = TimezonePeriod.new(nil, t3)
|
450
|
-
p8 = TimezonePeriod.new(nil, t3)
|
451
|
-
p9 = TimezonePeriod.new(nil, t4)
|
452
|
-
p10 = TimezonePeriod.new(nil, nil, o1)
|
453
|
-
p11 = TimezonePeriod.new(nil, nil, o1)
|
454
|
-
p12 = TimezonePeriod.new(nil, nil, o2)
|
455
|
-
|
456
|
-
assert_equal(true, p1 == p1)
|
457
|
-
assert_equal(true, p1 == p2)
|
458
|
-
assert_equal(true, p1 == p3)
|
459
|
-
assert_equal(false, p1 == p4)
|
460
|
-
assert_equal(false, p1 == p5)
|
461
|
-
assert_equal(false, p1 == p6)
|
462
|
-
assert_equal(false, p1 == p7)
|
463
|
-
assert_equal(false, p1 == p8)
|
464
|
-
assert_equal(false, p1 == p9)
|
465
|
-
assert_equal(false, p1 == p10)
|
466
|
-
assert_equal(false, p1 == p11)
|
467
|
-
assert_equal(false, p1 == p12)
|
468
|
-
assert_equal(false, p1 == Object.new)
|
469
|
-
|
470
|
-
assert_equal(true, p4 == p4)
|
471
|
-
assert_equal(true, p4 == p5)
|
472
|
-
assert_equal(false, p4 == p6)
|
473
|
-
assert_equal(false, p4 == Object.new)
|
474
|
-
|
475
|
-
assert_equal(true, p7 == p7)
|
476
|
-
assert_equal(true, p7 == p8)
|
477
|
-
assert_equal(false, p7 == p9)
|
478
|
-
assert_equal(false, p7 == Object.new)
|
479
|
-
|
480
|
-
assert_equal(true, p10 == p10)
|
481
|
-
assert_equal(true, p10 == p11)
|
482
|
-
assert_equal(false, p10 == p12)
|
483
|
-
assert_equal(false, p10 == Object.new)
|
484
|
-
end
|
485
|
-
|
486
|
-
def test_eql
|
487
|
-
o1 = TimezoneOffset.new(0, 3600, :TEST)
|
488
|
-
o2 = TimezoneOffset.new(0, 0, :TEST)
|
489
|
-
t1 = TestTimezoneTransition.new(o1, o2, 1149368400)
|
490
|
-
t2 = TestTimezoneTransition.new(o1, o2, DateTime.new(2006, 6, 3, 21, 0, 0))
|
491
|
-
t3 = TestTimezoneTransition.new(o1, o2, 1149454800)
|
492
|
-
t4 = TestTimezoneTransition.new(o1, o2, 1149541200)
|
493
|
-
|
494
|
-
p1 = TimezonePeriod.new(t1, t3)
|
495
|
-
p2 = TimezonePeriod.new(t1, t3)
|
496
|
-
p3 = TimezonePeriod.new(t2, t3)
|
497
|
-
p4 = TimezonePeriod.new(t3, nil)
|
498
|
-
p5 = TimezonePeriod.new(t3, nil)
|
499
|
-
p6 = TimezonePeriod.new(t4, nil)
|
500
|
-
p7 = TimezonePeriod.new(nil, t3)
|
501
|
-
p8 = TimezonePeriod.new(nil, t3)
|
502
|
-
p9 = TimezonePeriod.new(nil, t4)
|
503
|
-
p10 = TimezonePeriod.new(nil, nil, o1)
|
504
|
-
p11 = TimezonePeriod.new(nil, nil, o1)
|
505
|
-
p12 = TimezonePeriod.new(nil, nil, o2)
|
506
|
-
|
507
|
-
assert_equal(true, p1.eql?(p1))
|
508
|
-
assert_equal(true, p1.eql?(p2))
|
509
|
-
assert_equal(false, p1.eql?(p3))
|
510
|
-
assert_equal(false, p1.eql?(p4))
|
511
|
-
assert_equal(false, p1.eql?(p5))
|
512
|
-
assert_equal(false, p1.eql?(p6))
|
513
|
-
assert_equal(false, p1.eql?(p7))
|
514
|
-
assert_equal(false, p1.eql?(p8))
|
515
|
-
assert_equal(false, p1.eql?(p9))
|
516
|
-
assert_equal(false, p1.eql?(p10))
|
517
|
-
assert_equal(false, p1.eql?(p11))
|
518
|
-
assert_equal(false, p1.eql?(p12))
|
519
|
-
assert_equal(false, p1.eql?(Object.new))
|
520
|
-
|
521
|
-
assert_equal(true, p4.eql?(p4))
|
522
|
-
assert_equal(true, p4.eql?(p5))
|
523
|
-
assert_equal(false, p4.eql?(p6))
|
524
|
-
assert_equal(false, p4.eql?(Object.new))
|
525
|
-
|
526
|
-
assert_equal(true, p7.eql?(p7))
|
527
|
-
assert_equal(true, p7.eql?(p8))
|
528
|
-
assert_equal(false, p7.eql?(p9))
|
529
|
-
assert_equal(false, p7.eql?(Object.new))
|
530
|
-
|
531
|
-
assert_equal(true, p10.eql?(p10))
|
532
|
-
assert_equal(true, p10.eql?(p11))
|
533
|
-
assert_equal(false, p10.eql?(p12))
|
534
|
-
assert_equal(false, p10.eql?(Object.new))
|
535
|
-
end
|
536
|
-
|
537
|
-
def test_hash
|
538
|
-
o1 = TimezoneOffset.new(0, 3600, :TEST)
|
539
|
-
o2 = TimezoneOffset.new(0, 0, :TEST)
|
540
|
-
t1 = TestTimezoneTransition.new(o1, o2, 1149368400)
|
541
|
-
t2 = TestTimezoneTransition.new(o1, o2, DateTime.new(2006, 6, 3, 21, 0, 0))
|
542
|
-
t3 = TestTimezoneTransition.new(o1, o2, 1149454800)
|
543
|
-
t4 = TestTimezoneTransition.new(o1, o2, 1149541200)
|
544
|
-
|
545
|
-
p1 = TimezonePeriod.new(t1, t3)
|
546
|
-
p2 = TimezonePeriod.new(t2, nil)
|
547
|
-
p3 = TimezonePeriod.new(nil, t4)
|
548
|
-
p4 = TimezonePeriod.new(nil, nil, o1)
|
549
|
-
|
550
|
-
assert_equal(t1.hash ^ t3.hash, p1.hash)
|
551
|
-
assert_equal(t2.hash ^ nil.hash, p2.hash)
|
552
|
-
assert_equal(nil.hash ^ t4.hash, p3.hash)
|
553
|
-
assert_equal(nil.hash ^ nil.hash ^ o1.hash, p4.hash)
|
554
|
-
end
|
555
|
-
end
|