tzinfo 1.2.5 → 2.0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (148) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data/.yardopts +3 -0
  4. data/CHANGES.md +607 -377
  5. data/LICENSE +13 -13
  6. data/README.md +368 -113
  7. data/lib/tzinfo/annual_rules.rb +71 -0
  8. data/lib/tzinfo/country.rb +141 -129
  9. data/lib/tzinfo/country_timezone.rb +70 -112
  10. data/lib/tzinfo/data_source.rb +400 -144
  11. data/lib/tzinfo/data_sources/constant_offset_data_timezone_info.rb +56 -0
  12. data/lib/tzinfo/data_sources/country_info.rb +42 -0
  13. data/lib/tzinfo/data_sources/data_timezone_info.rb +91 -0
  14. data/lib/tzinfo/data_sources/linked_timezone_info.rb +33 -0
  15. data/lib/tzinfo/data_sources/posix_time_zone_parser.rb +181 -0
  16. data/lib/tzinfo/data_sources/ruby_data_source.rb +145 -0
  17. data/lib/tzinfo/data_sources/timezone_info.rb +47 -0
  18. data/lib/tzinfo/data_sources/transitions_data_timezone_info.rb +214 -0
  19. data/lib/tzinfo/data_sources/zoneinfo_data_source.rb +596 -0
  20. data/lib/tzinfo/data_sources/zoneinfo_reader.rb +486 -0
  21. data/lib/tzinfo/data_sources.rb +8 -0
  22. data/lib/tzinfo/data_timezone.rb +33 -47
  23. data/lib/tzinfo/datetime_with_offset.rb +153 -0
  24. data/lib/tzinfo/format1/country_definer.rb +17 -0
  25. data/lib/tzinfo/format1/country_index_definition.rb +64 -0
  26. data/lib/tzinfo/format1/timezone_definer.rb +64 -0
  27. data/lib/tzinfo/format1/timezone_definition.rb +39 -0
  28. data/lib/tzinfo/format1/timezone_index_definition.rb +77 -0
  29. data/lib/tzinfo/format1.rb +10 -0
  30. data/lib/tzinfo/format2/country_definer.rb +68 -0
  31. data/lib/tzinfo/format2/country_index_definer.rb +68 -0
  32. data/lib/tzinfo/format2/country_index_definition.rb +46 -0
  33. data/lib/tzinfo/format2/timezone_definer.rb +94 -0
  34. data/lib/tzinfo/format2/timezone_definition.rb +73 -0
  35. data/lib/tzinfo/format2/timezone_index_definer.rb +45 -0
  36. data/lib/tzinfo/format2/timezone_index_definition.rb +55 -0
  37. data/lib/tzinfo/format2.rb +10 -0
  38. data/lib/tzinfo/info_timezone.rb +26 -21
  39. data/lib/tzinfo/linked_timezone.rb +33 -52
  40. data/lib/tzinfo/offset_timezone_period.rb +42 -0
  41. data/lib/tzinfo/string_deduper.rb +118 -0
  42. data/lib/tzinfo/time_with_offset.rb +154 -0
  43. data/lib/tzinfo/timestamp.rb +552 -0
  44. data/lib/tzinfo/timestamp_with_offset.rb +85 -0
  45. data/lib/tzinfo/timezone.rb +989 -498
  46. data/lib/tzinfo/timezone_offset.rb +84 -74
  47. data/lib/tzinfo/timezone_period.rb +151 -217
  48. data/lib/tzinfo/timezone_proxy.rb +70 -79
  49. data/lib/tzinfo/timezone_transition.rb +77 -109
  50. data/lib/tzinfo/transition_rule.rb +455 -0
  51. data/lib/tzinfo/transitions_timezone_period.rb +63 -0
  52. data/lib/tzinfo/untaint_ext.rb +18 -0
  53. data/lib/tzinfo/version.rb +7 -0
  54. data/lib/tzinfo/with_offset.rb +61 -0
  55. data/lib/tzinfo.rb +74 -29
  56. data.tar.gz.sig +0 -0
  57. metadata +72 -122
  58. metadata.gz.sig +0 -0
  59. data/Rakefile +0 -107
  60. data/lib/tzinfo/country_index_definition.rb +0 -31
  61. data/lib/tzinfo/country_info.rb +0 -42
  62. data/lib/tzinfo/data_timezone_info.rb +0 -55
  63. data/lib/tzinfo/linked_timezone_info.rb +0 -26
  64. data/lib/tzinfo/offset_rationals.rb +0 -77
  65. data/lib/tzinfo/ruby_core_support.rb +0 -146
  66. data/lib/tzinfo/ruby_country_info.rb +0 -74
  67. data/lib/tzinfo/ruby_data_source.rb +0 -136
  68. data/lib/tzinfo/time_or_datetime.rb +0 -340
  69. data/lib/tzinfo/timezone_definition.rb +0 -36
  70. data/lib/tzinfo/timezone_index_definition.rb +0 -54
  71. data/lib/tzinfo/timezone_info.rb +0 -30
  72. data/lib/tzinfo/timezone_transition_definition.rb +0 -104
  73. data/lib/tzinfo/transition_data_timezone_info.rb +0 -274
  74. data/lib/tzinfo/zoneinfo_country_info.rb +0 -37
  75. data/lib/tzinfo/zoneinfo_data_source.rb +0 -488
  76. data/lib/tzinfo/zoneinfo_timezone_info.rb +0 -296
  77. data/test/tc_country.rb +0 -234
  78. data/test/tc_country_index_definition.rb +0 -69
  79. data/test/tc_country_info.rb +0 -16
  80. data/test/tc_country_timezone.rb +0 -173
  81. data/test/tc_data_source.rb +0 -218
  82. data/test/tc_data_timezone.rb +0 -99
  83. data/test/tc_data_timezone_info.rb +0 -18
  84. data/test/tc_info_timezone.rb +0 -34
  85. data/test/tc_linked_timezone.rb +0 -155
  86. data/test/tc_linked_timezone_info.rb +0 -23
  87. data/test/tc_offset_rationals.rb +0 -23
  88. data/test/tc_ruby_core_support.rb +0 -168
  89. data/test/tc_ruby_country_info.rb +0 -110
  90. data/test/tc_ruby_data_source.rb +0 -143
  91. data/test/tc_time_or_datetime.rb +0 -654
  92. data/test/tc_timezone.rb +0 -1350
  93. data/test/tc_timezone_definition.rb +0 -113
  94. data/test/tc_timezone_index_definition.rb +0 -73
  95. data/test/tc_timezone_info.rb +0 -11
  96. data/test/tc_timezone_london.rb +0 -143
  97. data/test/tc_timezone_melbourne.rb +0 -142
  98. data/test/tc_timezone_new_york.rb +0 -142
  99. data/test/tc_timezone_offset.rb +0 -126
  100. data/test/tc_timezone_period.rb +0 -555
  101. data/test/tc_timezone_proxy.rb +0 -136
  102. data/test/tc_timezone_transition.rb +0 -366
  103. data/test/tc_timezone_transition_definition.rb +0 -295
  104. data/test/tc_timezone_utc.rb +0 -27
  105. data/test/tc_transition_data_timezone_info.rb +0 -423
  106. data/test/tc_zoneinfo_country_info.rb +0 -78
  107. data/test/tc_zoneinfo_data_source.rb +0 -1195
  108. data/test/tc_zoneinfo_timezone_info.rb +0 -1232
  109. data/test/test_utils.rb +0 -163
  110. data/test/ts_all.rb +0 -7
  111. data/test/ts_all_ruby.rb +0 -5
  112. data/test/ts_all_zoneinfo.rb +0 -7
  113. data/test/tzinfo-data/tzinfo/data/definitions/America/Argentina/Buenos_Aires.rb +0 -89
  114. data/test/tzinfo-data/tzinfo/data/definitions/America/New_York.rb +0 -315
  115. data/test/tzinfo-data/tzinfo/data/definitions/Australia/Melbourne.rb +0 -218
  116. data/test/tzinfo-data/tzinfo/data/definitions/EST.rb +0 -19
  117. data/test/tzinfo-data/tzinfo/data/definitions/Etc/GMT__m__1.rb +0 -21
  118. data/test/tzinfo-data/tzinfo/data/definitions/Etc/GMT__p__1.rb +0 -21
  119. data/test/tzinfo-data/tzinfo/data/definitions/Etc/UTC.rb +0 -21
  120. data/test/tzinfo-data/tzinfo/data/definitions/Europe/Amsterdam.rb +0 -261
  121. data/test/tzinfo-data/tzinfo/data/definitions/Europe/Andorra.rb +0 -186
  122. data/test/tzinfo-data/tzinfo/data/definitions/Europe/London.rb +0 -321
  123. data/test/tzinfo-data/tzinfo/data/definitions/Europe/Paris.rb +0 -265
  124. data/test/tzinfo-data/tzinfo/data/definitions/Europe/Prague.rb +0 -220
  125. data/test/tzinfo-data/tzinfo/data/definitions/UTC.rb +0 -16
  126. data/test/tzinfo-data/tzinfo/data/indexes/countries.rb +0 -927
  127. data/test/tzinfo-data/tzinfo/data/indexes/timezones.rb +0 -596
  128. data/test/tzinfo-data/tzinfo/data/version.rb +0 -14
  129. data/test/tzinfo-data/tzinfo/data.rb +0 -8
  130. data/test/zoneinfo/America/Argentina/Buenos_Aires +0 -0
  131. data/test/zoneinfo/America/New_York +0 -0
  132. data/test/zoneinfo/Australia/Melbourne +0 -0
  133. data/test/zoneinfo/EST +0 -0
  134. data/test/zoneinfo/Etc/UTC +0 -0
  135. data/test/zoneinfo/Europe/Amsterdam +0 -0
  136. data/test/zoneinfo/Europe/Andorra +0 -0
  137. data/test/zoneinfo/Europe/London +0 -0
  138. data/test/zoneinfo/Europe/Paris +0 -0
  139. data/test/zoneinfo/Europe/Prague +0 -0
  140. data/test/zoneinfo/Factory +0 -0
  141. data/test/zoneinfo/iso3166.tab +0 -275
  142. data/test/zoneinfo/leapseconds +0 -61
  143. data/test/zoneinfo/posix/Europe/London +0 -0
  144. data/test/zoneinfo/posixrules +0 -0
  145. data/test/zoneinfo/right/Europe/London +0 -0
  146. data/test/zoneinfo/zone.tab +0 -439
  147. data/test/zoneinfo/zone1970.tab +0 -369
  148. data/tzinfo.gemspec +0 -21
@@ -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
@@ -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