tzinfo 0.3.10 → 0.3.11

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of tzinfo might be problematic. Click here for more details.

data/CHANGES CHANGED
@@ -1,3 +1,15 @@
1
+ == Version 0.3.11 (tzdata v2008g) - 7-Oct-2008
2
+
3
+ * Updated to tzdata version 2008g
4
+ (http://article.gmane.org/gmane.comp.time.tz/2335).
5
+ * Support Ruby 1.9.0-5. Rational.new! has now been removed in Ruby 1.9.
6
+ Only use Rational.new! if it is available (it is preferable in Ruby 1.8
7
+ for performance reasons). Thanks to Jeremy Kemper and Pratik Naik for
8
+ reporting this. Closes #22312.
9
+ * Apply a patch from Pratik Naik to replace assert calls that have been
10
+ deprecated in the Ruby svn trunk. Closes #22308.
11
+
12
+
1
13
  == Version 0.3.10 (tzdata v2008f) - 16-Sep-2008
2
14
 
3
15
  * Updated to tzdata version 2008f
data/Rakefile CHANGED
@@ -16,7 +16,7 @@ require 'rake/rdoctask'
16
16
  require 'rake/gempackagetask'
17
17
  require 'fileutils'
18
18
 
19
- PKG_VERSION = "0.3.10"
19
+ PKG_VERSION = "0.3.11"
20
20
  PKG_FILES = FileList[
21
21
  'CHANGES',
22
22
  'LICENSE',
@@ -21,6 +21,7 @@
21
21
  #++
22
22
 
23
23
  require 'tzinfo/timezone'
24
+ require 'tzinfo/ruby_core_support'
24
25
 
25
26
  module TZInfo
26
27
  # A Timezone within a Country. This contains extra information about the
@@ -64,12 +65,12 @@ module TZInfo
64
65
 
65
66
  # The latitude of this timezone in degrees as a Rational.
66
67
  def latitude
67
- @latitude ||= Rational.send(:new!, @latitude_numerator, @latitude_denominator)
68
+ @latitude ||= RubyCoreSupport.rational_new!(@latitude_numerator, @latitude_denominator)
68
69
  end
69
70
 
70
71
  # The longitude of this timezone in degrees as a Rational.
71
72
  def longitude
72
- @longitude ||= Rational.send(:new!, @longitude_numerator, @longitude_denominator)
73
+ @longitude ||= RubyCoreSupport.rational_new!(@longitude_numerator, @longitude_denominator)
73
74
  end
74
75
 
75
76
  # Returns true if and only if the given CountryTimezone is equal to the
@@ -87,13 +87,13 @@ module TZInfo
87
87
  tz.transition 2010, 10, :o2, 1287288000
88
88
  tz.transition 2011, 2, :o1, 1298170800
89
89
  tz.transition 2011, 10, :o2, 1318737600
90
- tz.transition 2012, 2, :o1, 1329620400
90
+ tz.transition 2012, 2, :o1, 1330225200
91
91
  tz.transition 2012, 10, :o2, 1350792000
92
92
  tz.transition 2013, 2, :o1, 1361070000
93
93
  tz.transition 2013, 10, :o2, 1382241600
94
94
  tz.transition 2014, 2, :o1, 1392519600
95
95
  tz.transition 2014, 10, :o2, 1413691200
96
- tz.transition 2015, 2, :o1, 1423969200
96
+ tz.transition 2015, 2, :o1, 1424574000
97
97
  tz.transition 2015, 10, :o2, 1445140800
98
98
  tz.transition 2016, 2, :o1, 1456023600
99
99
  tz.transition 2016, 10, :o2, 1476590400
@@ -109,13 +109,13 @@ module TZInfo
109
109
  tz.transition 2021, 10, :o2, 1634443200
110
110
  tz.transition 2022, 2, :o1, 1645326000
111
111
  tz.transition 2022, 10, :o2, 1665892800
112
- tz.transition 2023, 2, :o1, 1676775600
112
+ tz.transition 2023, 2, :o1, 1677380400
113
113
  tz.transition 2023, 10, :o2, 1697342400
114
114
  tz.transition 2024, 2, :o1, 1708225200
115
115
  tz.transition 2024, 10, :o2, 1729396800
116
116
  tz.transition 2025, 2, :o1, 1739674800
117
117
  tz.transition 2025, 10, :o2, 1760846400
118
- tz.transition 2026, 2, :o1, 1771124400
118
+ tz.transition 2026, 2, :o1, 1771729200
119
119
  tz.transition 2026, 10, :o2, 1792296000
120
120
  tz.transition 2027, 2, :o1, 1803178800
121
121
  tz.transition 2027, 10, :o2, 1823745600
@@ -131,13 +131,13 @@ module TZInfo
131
131
  tz.transition 2032, 10, :o2, 1981598400
132
132
  tz.transition 2033, 2, :o1, 1992481200
133
133
  tz.transition 2033, 10, :o2, 2013048000
134
- tz.transition 2034, 2, :o1, 2023930800
134
+ tz.transition 2034, 2, :o1, 2024535600
135
135
  tz.transition 2034, 10, :o2, 2044497600
136
136
  tz.transition 2035, 2, :o1, 2055380400
137
137
  tz.transition 2035, 10, :o2, 2076552000
138
138
  tz.transition 2036, 2, :o1, 2086830000
139
139
  tz.transition 2036, 10, :o2, 2108001600
140
- tz.transition 2037, 2, :o1, 2118279600
140
+ tz.transition 2037, 2, :o1, 2118884400
141
141
  tz.transition 2037, 10, :o2, 2139451200
142
142
  tz.transition 2038, 2, :o1, 19723805, 8
143
143
  tz.transition 2038, 10, :o2, 7397141, 3
@@ -85,13 +85,13 @@ module TZInfo
85
85
  tz.transition 2010, 10, :o2, 1287288000
86
86
  tz.transition 2011, 2, :o1, 1298170800
87
87
  tz.transition 2011, 10, :o2, 1318737600
88
- tz.transition 2012, 2, :o1, 1329620400
88
+ tz.transition 2012, 2, :o1, 1330225200
89
89
  tz.transition 2012, 10, :o2, 1350792000
90
90
  tz.transition 2013, 2, :o1, 1361070000
91
91
  tz.transition 2013, 10, :o2, 1382241600
92
92
  tz.transition 2014, 2, :o1, 1392519600
93
93
  tz.transition 2014, 10, :o2, 1413691200
94
- tz.transition 2015, 2, :o1, 1423969200
94
+ tz.transition 2015, 2, :o1, 1424574000
95
95
  tz.transition 2015, 10, :o2, 1445140800
96
96
  tz.transition 2016, 2, :o1, 1456023600
97
97
  tz.transition 2016, 10, :o2, 1476590400
@@ -107,13 +107,13 @@ module TZInfo
107
107
  tz.transition 2021, 10, :o2, 1634443200
108
108
  tz.transition 2022, 2, :o1, 1645326000
109
109
  tz.transition 2022, 10, :o2, 1665892800
110
- tz.transition 2023, 2, :o1, 1676775600
110
+ tz.transition 2023, 2, :o1, 1677380400
111
111
  tz.transition 2023, 10, :o2, 1697342400
112
112
  tz.transition 2024, 2, :o1, 1708225200
113
113
  tz.transition 2024, 10, :o2, 1729396800
114
114
  tz.transition 2025, 2, :o1, 1739674800
115
115
  tz.transition 2025, 10, :o2, 1760846400
116
- tz.transition 2026, 2, :o1, 1771124400
116
+ tz.transition 2026, 2, :o1, 1771729200
117
117
  tz.transition 2026, 10, :o2, 1792296000
118
118
  tz.transition 2027, 2, :o1, 1803178800
119
119
  tz.transition 2027, 10, :o2, 1823745600
@@ -129,13 +129,13 @@ module TZInfo
129
129
  tz.transition 2032, 10, :o2, 1981598400
130
130
  tz.transition 2033, 2, :o1, 1992481200
131
131
  tz.transition 2033, 10, :o2, 2013048000
132
- tz.transition 2034, 2, :o1, 2023930800
132
+ tz.transition 2034, 2, :o1, 2024535600
133
133
  tz.transition 2034, 10, :o2, 2044497600
134
134
  tz.transition 2035, 2, :o1, 2055380400
135
135
  tz.transition 2035, 10, :o2, 2076552000
136
136
  tz.transition 2036, 2, :o1, 2086830000
137
137
  tz.transition 2036, 10, :o2, 2108001600
138
- tz.transition 2037, 2, :o1, 2118279600
138
+ tz.transition 2037, 2, :o1, 2118884400
139
139
  tz.transition 2037, 10, :o2, 2139451200
140
140
  tz.transition 2038, 2, :o1, 19723805, 8
141
141
  tz.transition 2038, 10, :o2, 7397141, 3
@@ -87,13 +87,13 @@ module TZInfo
87
87
  tz.transition 2010, 10, :o2, 1287284400
88
88
  tz.transition 2011, 2, :o1, 1298167200
89
89
  tz.transition 2011, 10, :o2, 1318734000
90
- tz.transition 2012, 2, :o1, 1329616800
90
+ tz.transition 2012, 2, :o1, 1330221600
91
91
  tz.transition 2012, 10, :o2, 1350788400
92
92
  tz.transition 2013, 2, :o1, 1361066400
93
93
  tz.transition 2013, 10, :o2, 1382238000
94
94
  tz.transition 2014, 2, :o1, 1392516000
95
95
  tz.transition 2014, 10, :o2, 1413687600
96
- tz.transition 2015, 2, :o1, 1423965600
96
+ tz.transition 2015, 2, :o1, 1424570400
97
97
  tz.transition 2015, 10, :o2, 1445137200
98
98
  tz.transition 2016, 2, :o1, 1456020000
99
99
  tz.transition 2016, 10, :o2, 1476586800
@@ -109,13 +109,13 @@ module TZInfo
109
109
  tz.transition 2021, 10, :o2, 1634439600
110
110
  tz.transition 2022, 2, :o1, 1645322400
111
111
  tz.transition 2022, 10, :o2, 1665889200
112
- tz.transition 2023, 2, :o1, 1676772000
112
+ tz.transition 2023, 2, :o1, 1677376800
113
113
  tz.transition 2023, 10, :o2, 1697338800
114
114
  tz.transition 2024, 2, :o1, 1708221600
115
115
  tz.transition 2024, 10, :o2, 1729393200
116
116
  tz.transition 2025, 2, :o1, 1739671200
117
117
  tz.transition 2025, 10, :o2, 1760842800
118
- tz.transition 2026, 2, :o1, 1771120800
118
+ tz.transition 2026, 2, :o1, 1771725600
119
119
  tz.transition 2026, 10, :o2, 1792292400
120
120
  tz.transition 2027, 2, :o1, 1803175200
121
121
  tz.transition 2027, 10, :o2, 1823742000
@@ -131,13 +131,13 @@ module TZInfo
131
131
  tz.transition 2032, 10, :o2, 1981594800
132
132
  tz.transition 2033, 2, :o1, 1992477600
133
133
  tz.transition 2033, 10, :o2, 2013044400
134
- tz.transition 2034, 2, :o1, 2023927200
134
+ tz.transition 2034, 2, :o1, 2024532000
135
135
  tz.transition 2034, 10, :o2, 2044494000
136
136
  tz.transition 2035, 2, :o1, 2055376800
137
137
  tz.transition 2035, 10, :o2, 2076548400
138
138
  tz.transition 2036, 2, :o1, 2086826400
139
139
  tz.transition 2036, 10, :o2, 2107998000
140
- tz.transition 2037, 2, :o1, 2118276000
140
+ tz.transition 2037, 2, :o1, 2118880800
141
141
  tz.transition 2037, 10, :o2, 2139447600
142
142
  tz.transition 2038, 2, :o1, 29585707, 12
143
143
  tz.transition 2038, 10, :o2, 19725709, 8
@@ -20,6 +20,9 @@
20
20
  # THE SOFTWARE.
21
21
  #++
22
22
 
23
+ require 'rational'
24
+ require 'tzinfo/ruby_core_support'
25
+
23
26
  module TZInfo
24
27
 
25
28
  # Provides a method for getting Rationals for a timezone offset in seconds.
@@ -27,63 +30,63 @@ module TZInfo
27
30
  # -14 and +14 hours to avoid having to call gcd at runtime.
28
31
  module OffsetRationals #:nodoc:
29
32
  @@rational_cache = {
30
- -50400 => Rational.send(:new!, -7,12),
31
- -48600 => Rational.send(:new!, -9,16),
32
- -46800 => Rational.send(:new!, -13,24),
33
- -45000 => Rational.send(:new!, -25,48),
34
- -43200 => Rational.send(:new!, -1,2),
35
- -41400 => Rational.send(:new!, -23,48),
36
- -39600 => Rational.send(:new!, -11,24),
37
- -37800 => Rational.send(:new!, -7,16),
38
- -36000 => Rational.send(:new!, -5,12),
39
- -34200 => Rational.send(:new!, -19,48),
40
- -32400 => Rational.send(:new!, -3,8),
41
- -30600 => Rational.send(:new!, -17,48),
42
- -28800 => Rational.send(:new!, -1,3),
43
- -27000 => Rational.send(:new!, -5,16),
44
- -25200 => Rational.send(:new!, -7,24),
45
- -23400 => Rational.send(:new!, -13,48),
46
- -21600 => Rational.send(:new!, -1,4),
47
- -19800 => Rational.send(:new!, -11,48),
48
- -18000 => Rational.send(:new!, -5,24),
49
- -16200 => Rational.send(:new!, -3,16),
50
- -14400 => Rational.send(:new!, -1,6),
51
- -12600 => Rational.send(:new!, -7,48),
52
- -10800 => Rational.send(:new!, -1,8),
53
- -9000 => Rational.send(:new!, -5,48),
54
- -7200 => Rational.send(:new!, -1,12),
55
- -5400 => Rational.send(:new!, -1,16),
56
- -3600 => Rational.send(:new!, -1,24),
57
- -1800 => Rational.send(:new!, -1,48),
58
- 0 => Rational.send(:new!, 0,1),
59
- 1800 => Rational.send(:new!, 1,48),
60
- 3600 => Rational.send(:new!, 1,24),
61
- 5400 => Rational.send(:new!, 1,16),
62
- 7200 => Rational.send(:new!, 1,12),
63
- 9000 => Rational.send(:new!, 5,48),
64
- 10800 => Rational.send(:new!, 1,8),
65
- 12600 => Rational.send(:new!, 7,48),
66
- 14400 => Rational.send(:new!, 1,6),
67
- 16200 => Rational.send(:new!, 3,16),
68
- 18000 => Rational.send(:new!, 5,24),
69
- 19800 => Rational.send(:new!, 11,48),
70
- 21600 => Rational.send(:new!, 1,4),
71
- 23400 => Rational.send(:new!, 13,48),
72
- 25200 => Rational.send(:new!, 7,24),
73
- 27000 => Rational.send(:new!, 5,16),
74
- 28800 => Rational.send(:new!, 1,3),
75
- 30600 => Rational.send(:new!, 17,48),
76
- 32400 => Rational.send(:new!, 3,8),
77
- 34200 => Rational.send(:new!, 19,48),
78
- 36000 => Rational.send(:new!, 5,12),
79
- 37800 => Rational.send(:new!, 7,16),
80
- 39600 => Rational.send(:new!, 11,24),
81
- 41400 => Rational.send(:new!, 23,48),
82
- 43200 => Rational.send(:new!, 1,2),
83
- 45000 => Rational.send(:new!, 25,48),
84
- 46800 => Rational.send(:new!, 13,24),
85
- 48600 => Rational.send(:new!, 9,16),
86
- 50400 => Rational.send(:new!, 7,12)}
33
+ -50400 => RubyCoreSupport.rational_new!(-7,12),
34
+ -48600 => RubyCoreSupport.rational_new!(-9,16),
35
+ -46800 => RubyCoreSupport.rational_new!(-13,24),
36
+ -45000 => RubyCoreSupport.rational_new!(-25,48),
37
+ -43200 => RubyCoreSupport.rational_new!(-1,2),
38
+ -41400 => RubyCoreSupport.rational_new!(-23,48),
39
+ -39600 => RubyCoreSupport.rational_new!(-11,24),
40
+ -37800 => RubyCoreSupport.rational_new!(-7,16),
41
+ -36000 => RubyCoreSupport.rational_new!(-5,12),
42
+ -34200 => RubyCoreSupport.rational_new!(-19,48),
43
+ -32400 => RubyCoreSupport.rational_new!(-3,8),
44
+ -30600 => RubyCoreSupport.rational_new!(-17,48),
45
+ -28800 => RubyCoreSupport.rational_new!(-1,3),
46
+ -27000 => RubyCoreSupport.rational_new!(-5,16),
47
+ -25200 => RubyCoreSupport.rational_new!(-7,24),
48
+ -23400 => RubyCoreSupport.rational_new!(-13,48),
49
+ -21600 => RubyCoreSupport.rational_new!(-1,4),
50
+ -19800 => RubyCoreSupport.rational_new!(-11,48),
51
+ -18000 => RubyCoreSupport.rational_new!(-5,24),
52
+ -16200 => RubyCoreSupport.rational_new!(-3,16),
53
+ -14400 => RubyCoreSupport.rational_new!(-1,6),
54
+ -12600 => RubyCoreSupport.rational_new!(-7,48),
55
+ -10800 => RubyCoreSupport.rational_new!(-1,8),
56
+ -9000 => RubyCoreSupport.rational_new!(-5,48),
57
+ -7200 => RubyCoreSupport.rational_new!(-1,12),
58
+ -5400 => RubyCoreSupport.rational_new!(-1,16),
59
+ -3600 => RubyCoreSupport.rational_new!(-1,24),
60
+ -1800 => RubyCoreSupport.rational_new!(-1,48),
61
+ 0 => RubyCoreSupport.rational_new!(0,1),
62
+ 1800 => RubyCoreSupport.rational_new!(1,48),
63
+ 3600 => RubyCoreSupport.rational_new!(1,24),
64
+ 5400 => RubyCoreSupport.rational_new!(1,16),
65
+ 7200 => RubyCoreSupport.rational_new!(1,12),
66
+ 9000 => RubyCoreSupport.rational_new!(5,48),
67
+ 10800 => RubyCoreSupport.rational_new!(1,8),
68
+ 12600 => RubyCoreSupport.rational_new!(7,48),
69
+ 14400 => RubyCoreSupport.rational_new!(1,6),
70
+ 16200 => RubyCoreSupport.rational_new!(3,16),
71
+ 18000 => RubyCoreSupport.rational_new!(5,24),
72
+ 19800 => RubyCoreSupport.rational_new!(11,48),
73
+ 21600 => RubyCoreSupport.rational_new!(1,4),
74
+ 23400 => RubyCoreSupport.rational_new!(13,48),
75
+ 25200 => RubyCoreSupport.rational_new!(7,24),
76
+ 27000 => RubyCoreSupport.rational_new!(5,16),
77
+ 28800 => RubyCoreSupport.rational_new!(1,3),
78
+ 30600 => RubyCoreSupport.rational_new!(17,48),
79
+ 32400 => RubyCoreSupport.rational_new!(3,8),
80
+ 34200 => RubyCoreSupport.rational_new!(19,48),
81
+ 36000 => RubyCoreSupport.rational_new!(5,12),
82
+ 37800 => RubyCoreSupport.rational_new!(7,16),
83
+ 39600 => RubyCoreSupport.rational_new!(11,24),
84
+ 41400 => RubyCoreSupport.rational_new!(23,48),
85
+ 43200 => RubyCoreSupport.rational_new!(1,2),
86
+ 45000 => RubyCoreSupport.rational_new!(25,48),
87
+ 46800 => RubyCoreSupport.rational_new!(13,24),
88
+ 48600 => RubyCoreSupport.rational_new!(9,16),
89
+ 50400 => RubyCoreSupport.rational_new!(7,12)}
87
90
 
88
91
  # Returns a Rational expressing the fraction of a day that offset in
89
92
  # seconds represents (i.e. equivalent to Rational(offset, 86400)).
@@ -0,0 +1,56 @@
1
+ #--
2
+ # Copyright (c) 2008 Philip Ross
3
+ #
4
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ # of this software and associated documentation files (the "Software"), to deal
6
+ # in the Software without restriction, including without limitation the rights
7
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ # copies of the Software, and to permit persons to whom the Software is
9
+ # furnished to do so, subject to the following conditions:
10
+ #
11
+ # The above copyright notice and this permission notice shall be included in all
12
+ # copies or substantial portions of the Software.
13
+ #
14
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20
+ # THE SOFTWARE.
21
+ #++
22
+
23
+ require 'date'
24
+ require 'rational'
25
+
26
+ module TZInfo
27
+
28
+ # Methods to support different versions of Ruby.
29
+ module RubyCoreSupport #:nodoc:
30
+
31
+ # Use Rational.new! for performance reasons in Ruby 1.8.
32
+ # This has been removed from 1.9, but Rational performs better.
33
+ if Rational.respond_to? :new!
34
+ def self.rational_new!(numerator, denominator = 1)
35
+ Rational.new!(numerator, denominator)
36
+ end
37
+ else
38
+ def self.rational_new!(numerator, denominator = 1)
39
+ Rational(numerator, denominator)
40
+ end
41
+ end
42
+
43
+ # Ruby 1.8.6 introduced new! and deprecated new0.
44
+ # Ruby 1.9.0 removed new0.
45
+ # We still need to support new0 for older versions of Ruby.
46
+ if DateTime.respond_to? :new!
47
+ def self.datetime_new!(ajd = 0, of = 0, sg = Date::ITALY)
48
+ DateTime.new!(ajd, of, sg)
49
+ end
50
+ else
51
+ def self.datetime_new!(ajd = 0, of = 0, sg = Date::ITALY)
52
+ DateTime.new0(ajd, of, sg)
53
+ end
54
+ end
55
+ end
56
+ end
@@ -70,17 +70,8 @@ module TZInfo
70
70
  unless @denominator
71
71
  @at = TimeOrDateTime.new(@numerator_or_time)
72
72
  else
73
- r = Rational.send(:new!, @numerator_or_time, @denominator)
74
-
75
- # Ruby 1.8.6 introduced new! and deprecated new0.
76
- # Ruby 1.9.0 removed new0.
77
- # We still need to support new0 for older versions of Ruby.
78
- if DateTime.respond_to? :new!
79
- dt = DateTime.new!(r, 0, Date::ITALY)
80
- else
81
- dt = DateTime.new0(r, 0, Date::ITALY)
82
- end
83
-
73
+ r = RubyCoreSupport.rational_new!(@numerator_or_time, @denominator)
74
+ dt = RubyCoreSupport.datetime_new!(r, 0, Date::ITALY)
84
75
  @at = TimeOrDateTime.new(dt)
85
76
  end
86
77
  end
data/test/tc_country.rb CHANGED
@@ -9,36 +9,36 @@ class TCCountry < Test::Unit::TestCase
9
9
  def test_get_valid
10
10
  c = Country.get('GB')
11
11
 
12
- assert_not_nil(c)
12
+ assert c
13
13
  assert_equal('GB', c.code)
14
14
  end
15
15
 
16
16
  def test_get_not_exist
17
- assert_raise(InvalidCountryCode) {
17
+ assert_raises(InvalidCountryCode) {
18
18
  Country.get('ZZ')
19
19
  }
20
20
  end
21
21
 
22
22
  def test_get_invalid
23
- assert_raise(InvalidCountryCode) {
23
+ assert_raises(InvalidCountryCode) {
24
24
  Country.get('../Countries/GB')
25
25
  }
26
26
  end
27
27
 
28
28
  def test_get_nil
29
- assert_raise(InvalidCountryCode) {
29
+ assert_raises(InvalidCountryCode) {
30
30
  Country.get(nil)
31
31
  }
32
32
  end
33
33
 
34
34
  def test_get_case
35
- assert_raise(InvalidCountryCode) {
35
+ assert_raises(InvalidCountryCode) {
36
36
  Country.get('gb')
37
37
  }
38
38
  end
39
39
 
40
40
  def test_new_nil
41
- assert_raise(InvalidCountryCode) {
41
+ assert_raises(InvalidCountryCode) {
42
42
  c = Country.new(nil)
43
43
  }
44
44
  end
@@ -49,7 +49,7 @@ class TCCountry < Test::Unit::TestCase
49
49
  end
50
50
 
51
51
  def test_new_arg_not_exist
52
- assert_raise(InvalidCountryCode) {
52
+ assert_raises(InvalidCountryCode) {
53
53
  Country.new('ZZ')
54
54
  }
55
55
  end
@@ -17,7 +17,8 @@ class TCDataTimezoneInfo < Test::Unit::TestCase
17
17
  def test_offset
18
18
  dti = DataTimezoneInfo.new('Test/Zone')
19
19
 
20
- assert_nothing_raised { dti.offset :o1, -18000, 3600, :TEST }
20
+ # Test nothing raised
21
+ dti.offset :o1, -18000, 3600, :TEST
21
22
  end
22
23
 
23
24
  def test_offset_already_defined
@@ -25,21 +26,23 @@ class TCDataTimezoneInfo < Test::Unit::TestCase
25
26
  dti.offset :o1, 3600, 0, :TEST
26
27
  dti.offset :o2, 1800, 0, :TEST2
27
28
 
28
- assert_raise(ArgumentError) { dti.offset :o1, 3600, 3600, :TESTD }
29
+ assert_raises(ArgumentError) { dti.offset :o1, 3600, 3600, :TESTD }
29
30
  end
30
31
 
31
32
  def test_transition_time
32
33
  dti = DataTimezoneInfo.new('Test/Zone')
33
34
  dti.offset :o1, -18000, 3600, :TEST
34
35
 
35
- assert_nothing_raised { dti.transition 2006, 6, :o1, 1149368400 }
36
+ # Test nothing raised
37
+ dti.transition 2006, 6, :o1, 1149368400
36
38
  end
37
39
 
38
40
  def test_transition_datetime
39
41
  dti = DataTimezoneInfo.new('Test/Zone')
40
42
  dti.offset :o1, -18000, 3600, :TEST
41
43
 
42
- assert_nothing_raised { dti.transition 2006, 6, :o1, 19631123, 8 }
44
+ # Test nothing raised
45
+ dti.transition 2006, 6, :o1, 19631123, 8
43
46
  end
44
47
 
45
48
  def test_transition_invalid_offset
@@ -48,13 +51,13 @@ class TCDataTimezoneInfo < Test::Unit::TestCase
48
51
 
49
52
  dti.transition 2006, 6, :o1, 1149368400
50
53
 
51
- assert_raise(ArgumentError) { dti.transition 2006, 6, :o2, 1149454800 }
54
+ assert_raises(ArgumentError) { dti.transition 2006, 6, :o2, 1149454800 }
52
55
  end
53
56
 
54
57
  def test_transition_no_offsets
55
58
  dti = DataTimezoneInfo.new('Test/Zone')
56
59
 
57
- assert_raise(ArgumentError) { dti.transition 2006, 6, :o1, 1149368400 }
60
+ assert_raises(ArgumentError) { dti.transition 2006, 6, :o1, 1149368400 }
58
61
  end
59
62
 
60
63
  def test_transition_invalid_order_month
@@ -63,7 +66,7 @@ class TCDataTimezoneInfo < Test::Unit::TestCase
63
66
 
64
67
  dti.transition 2006, 6, :o1, 1149368400
65
68
 
66
- assert_raise(ArgumentError) { dti.transition 2006, 5, :o2, 1146690000 }
69
+ assert_raises(ArgumentError) { dti.transition 2006, 5, :o2, 1146690000 }
67
70
  end
68
71
 
69
72
  def test_transition_invalid_order_year
@@ -72,7 +75,7 @@ class TCDataTimezoneInfo < Test::Unit::TestCase
72
75
 
73
76
  dti.transition 2006, 6, :o1, 1149368400
74
77
 
75
- assert_raise(ArgumentError) { dti.transition 2005, 7, :o2, 1120424400 }
78
+ assert_raises(ArgumentError) { dti.transition 2005, 7, :o2, 1120424400 }
76
79
  end
77
80
 
78
81
  def test_period_for_utc
@@ -143,9 +146,9 @@ class TCDataTimezoneInfo < Test::Unit::TestCase
143
146
  def test_period_for_utc_no_offsets
144
147
  dti = DataTimezoneInfo.new('Test/Zone')
145
148
 
146
- assert_raise(NoOffsetsDefined) { dti.period_for_utc(DateTime.new(2005,1,1,0,0,0)) }
147
- assert_raise(NoOffsetsDefined) { dti.period_for_utc(Time.utc(2005,1,1,0,0,0)) }
148
- assert_raise(NoOffsetsDefined) { dti.period_for_utc(Time.utc(2005,1,1,0,0,0).to_i) }
149
+ assert_raises(NoOffsetsDefined) { dti.period_for_utc(DateTime.new(2005,1,1,0,0,0)) }
150
+ assert_raises(NoOffsetsDefined) { dti.period_for_utc(Time.utc(2005,1,1,0,0,0)) }
151
+ assert_raises(NoOffsetsDefined) { dti.period_for_utc(Time.utc(2005,1,1,0,0,0).to_i) }
149
152
  end
150
153
 
151
154
  def test_periods_for_local
@@ -275,8 +278,8 @@ class TCDataTimezoneInfo < Test::Unit::TestCase
275
278
  def test_periods_for_local_no_offsets
276
279
  dti = DataTimezoneInfo.new('Test/Zone')
277
280
 
278
- assert_raise(NoOffsetsDefined) { dti.periods_for_local(DateTime.new(2005,1,1,0,0,0)) }
279
- assert_raise(NoOffsetsDefined) { dti.periods_for_local(Time.utc(2005,1,1,0,0,0)) }
280
- assert_raise(NoOffsetsDefined) { dti.periods_for_local(Time.utc(2005,1,1,0,0,0).to_i) }
281
+ assert_raises(NoOffsetsDefined) { dti.periods_for_local(DateTime.new(2005,1,1,0,0,0)) }
282
+ assert_raises(NoOffsetsDefined) { dti.periods_for_local(Time.utc(2005,1,1,0,0,0)) }
283
+ assert_raises(NoOffsetsDefined) { dti.periods_for_local(Time.utc(2005,1,1,0,0,0).to_i) }
281
284
  end
282
285
  end
@@ -74,7 +74,7 @@ class TCLinkedTimezone < Test::Unit::TestCase
74
74
  end
75
75
 
76
76
  def test_invalid_linked_identifier
77
- assert_raise(InvalidTimezoneIdentifier) { LinkedTimezone.new(LinkedTimezoneInfo.new('Test/Zone', 'Invalid/Identifier')) }
77
+ assert_raises(InvalidTimezoneIdentifier) { LinkedTimezone.new(LinkedTimezoneInfo.new('Test/Zone', 'Invalid/Identifier')) }
78
78
  end
79
79
 
80
80
  def test_period_for_utc
@@ -97,7 +97,7 @@ class TCLinkedTimezone < Test::Unit::TestCase
97
97
  tz = LinkedTimezone.new(LinkedTimezoneInfo.new('Test/Zone', 'Test/No/Local'))
98
98
  linked_tz = Timezone.get('Test/No/Local')
99
99
  t = Time.utc(2006, 6, 27, 23, 12, 28)
100
- assert_raise(PeriodNotFound) { tz.periods_for_local(t) }
100
+ assert_raises(PeriodNotFound) { tz.periods_for_local(t) }
101
101
  assert_same(t, linked_tz.local)
102
102
  end
103
103
  end
@@ -0,0 +1,15 @@
1
+ $:.unshift File.join(File.dirname(__FILE__), "..", "lib")
2
+ require 'test/unit'
3
+ require 'tzinfo/ruby_core_support'
4
+
5
+ include TZInfo
6
+
7
+ class TCRubyCoreSupport < Test::Unit::TestCase
8
+ def test_rational_new!
9
+ assert_equal(Rational(3,4), RubyCoreSupport.rational_new!(3,4))
10
+ end
11
+
12
+ def test_datetime_new!
13
+ assert_equal(DateTime.new(2008,10,6,20,30,0, 1, Date::ITALY), RubyCoreSupport.datetime_new!(Rational(117827777, 48),1,2299161))
14
+ end
15
+ end
@@ -415,7 +415,7 @@ class TCTimeOrDateTime < Test::Unit::TestCase
415
415
  t + 1
416
416
  }
417
417
 
418
- assert_not_nil(t2)
418
+ assert t2
419
419
  assert_instance_of(TimeOrDateTime, t2)
420
420
  assert_equal(1143214324, t2.to_orig)
421
421
  end
data/test/tc_timezone.rb CHANGED
@@ -76,15 +76,15 @@ class TCTimezone < Test::Unit::TestCase
76
76
  end
77
77
 
78
78
  def test_get_not_exist
79
- assert_raise(InvalidTimezoneIdentifier) { Timezone.get('Nowhere/Special') }
79
+ assert_raises(InvalidTimezoneIdentifier) { Timezone.get('Nowhere/Special') }
80
80
  end
81
81
 
82
82
  def test_get_invalid
83
- assert_raise(InvalidTimezoneIdentifier) { Timezone.get('../Definitions/UTC') }
83
+ assert_raises(InvalidTimezoneIdentifier) { Timezone.get('../Definitions/UTC') }
84
84
  end
85
85
 
86
86
  def test_get_nil
87
- assert_raise(InvalidTimezoneIdentifier) { Timezone.get(nil) }
87
+ assert_raises(InvalidTimezoneIdentifier) { Timezone.get(nil) }
88
88
  end
89
89
 
90
90
  def test_get_plus
@@ -101,7 +101,7 @@ class TCTimezone < Test::Unit::TestCase
101
101
 
102
102
  def test_get_case
103
103
  Timezone.get('Europe/Prague')
104
- assert_raise(InvalidTimezoneIdentifier) { Timezone.get('Europe/prague') }
104
+ assert_raises(InvalidTimezoneIdentifier) { Timezone.get('Europe/prague') }
105
105
  end
106
106
 
107
107
  def test_get_proxy_valid
@@ -125,29 +125,29 @@ class TCTimezone < Test::Unit::TestCase
125
125
  def test_new_no_args
126
126
  tz = Timezone.new
127
127
 
128
- assert_raise(UnknownTimezone) { tz.identifier }
129
- assert_raise(UnknownTimezone) { tz.friendly_identifier }
130
- assert_raise(UnknownTimezone) { tz.utc_to_local(DateTime.new(2006,1,1,1,0,0)) }
131
- assert_raise(UnknownTimezone) { tz.local_to_utc(DateTime.new(2006,1,1,1,0,0)) }
132
- assert_raise(UnknownTimezone) { tz.period_for_utc(DateTime.new(2006,1,1,1,0,0)) }
133
- assert_raise(UnknownTimezone) { tz.periods_for_local(DateTime.new(2006,1,1,1,0,0)) }
134
- assert_raise(UnknownTimezone) { tz.period_for_local(DateTime.new(2006,1,1,1,0,0)) }
135
- assert_raise(UnknownTimezone) { tz.now }
136
- assert_raise(UnknownTimezone) { tz.current_period_and_time }
128
+ assert_raises(UnknownTimezone) { tz.identifier }
129
+ assert_raises(UnknownTimezone) { tz.friendly_identifier }
130
+ assert_raises(UnknownTimezone) { tz.utc_to_local(DateTime.new(2006,1,1,1,0,0)) }
131
+ assert_raises(UnknownTimezone) { tz.local_to_utc(DateTime.new(2006,1,1,1,0,0)) }
132
+ assert_raises(UnknownTimezone) { tz.period_for_utc(DateTime.new(2006,1,1,1,0,0)) }
133
+ assert_raises(UnknownTimezone) { tz.periods_for_local(DateTime.new(2006,1,1,1,0,0)) }
134
+ assert_raises(UnknownTimezone) { tz.period_for_local(DateTime.new(2006,1,1,1,0,0)) }
135
+ assert_raises(UnknownTimezone) { tz.now }
136
+ assert_raises(UnknownTimezone) { tz.current_period_and_time }
137
137
  end
138
138
 
139
139
  def test_new_nil
140
140
  tz = Timezone.new(nil)
141
141
 
142
- assert_raise(UnknownTimezone) { tz.identifier }
143
- assert_raise(UnknownTimezone) { tz.friendly_identifier }
144
- assert_raise(UnknownTimezone) { tz.utc_to_local(DateTime.new(2006,1,1,1,0,0)) }
145
- assert_raise(UnknownTimezone) { tz.local_to_utc(DateTime.new(2006,1,1,1,0,0)) }
146
- assert_raise(UnknownTimezone) { tz.period_for_utc(DateTime.new(2006,1,1,1,0,0)) }
147
- assert_raise(UnknownTimezone) { tz.periods_for_local(DateTime.new(2006,1,1,1,0,0)) }
148
- assert_raise(UnknownTimezone) { tz.period_for_local(DateTime.new(2006,1,1,1,0,0)) }
149
- assert_raise(UnknownTimezone) { tz.now }
150
- assert_raise(UnknownTimezone) { tz.current_period_and_time }
142
+ assert_raises(UnknownTimezone) { tz.identifier }
143
+ assert_raises(UnknownTimezone) { tz.friendly_identifier }
144
+ assert_raises(UnknownTimezone) { tz.utc_to_local(DateTime.new(2006,1,1,1,0,0)) }
145
+ assert_raises(UnknownTimezone) { tz.local_to_utc(DateTime.new(2006,1,1,1,0,0)) }
146
+ assert_raises(UnknownTimezone) { tz.period_for_utc(DateTime.new(2006,1,1,1,0,0)) }
147
+ assert_raises(UnknownTimezone) { tz.periods_for_local(DateTime.new(2006,1,1,1,0,0)) }
148
+ assert_raises(UnknownTimezone) { tz.period_for_local(DateTime.new(2006,1,1,1,0,0)) }
149
+ assert_raises(UnknownTimezone) { tz.now }
150
+ assert_raises(UnknownTimezone) { tz.current_period_and_time }
151
151
  end
152
152
 
153
153
  def test_new_arg
@@ -156,7 +156,7 @@ class TCTimezone < Test::Unit::TestCase
156
156
  end
157
157
 
158
158
  def test_new_arg_not_exist
159
- assert_raise(InvalidTimezoneIdentifier) { Timezone.new('Nowhere/Special') }
159
+ assert_raises(InvalidTimezoneIdentifier) { Timezone.new('Nowhere/Special') }
160
160
  end
161
161
 
162
162
  def test_all
@@ -245,12 +245,12 @@ class TCTimezone < Test::Unit::TestCase
245
245
  end
246
246
 
247
247
  def test_identifier
248
- assert_raise(UnknownTimezone) { Timezone.new.identifier }
248
+ assert_raises(UnknownTimezone) { Timezone.new.identifier }
249
249
  assert_equal('Europe/Paris', TestTimezone.new('Europe/Paris').identifier)
250
250
  end
251
251
 
252
252
  def test_name
253
- assert_raise(UnknownTimezone) { Timezone.new.name }
253
+ assert_raises(UnknownTimezone) { Timezone.new.name }
254
254
  assert_equal('Europe/Paris', TestTimezone.new('Europe/Paris').name)
255
255
  end
256
256
 
@@ -315,7 +315,7 @@ class TCTimezone < Test::Unit::TestCase
315
315
  dt = DateTime.new(2004,4,4,2,30,0)
316
316
  tz = TestTimezone.new('America/New_York', nil, [], dt)
317
317
 
318
- assert_raise(PeriodNotFound) do
318
+ assert_raises(PeriodNotFound) do
319
319
  tz.period_for_local(dt)
320
320
  end
321
321
  end
@@ -339,9 +339,9 @@ class TCTimezone < Test::Unit::TestCase
339
339
  t_tz = TestTimezone.new('America/New_York', nil, [p1, p2], t)
340
340
  i_tz = TestTimezone.new('America/New_York', nil, [p1, p2], i)
341
341
 
342
- assert_raise(AmbiguousTime) { dt_tz.period_for_local(dt) }
343
- assert_raise(AmbiguousTime) { t_tz.period_for_local(t) }
344
- assert_raise(AmbiguousTime) { i_tz.period_for_local(i) }
342
+ assert_raises(AmbiguousTime) { dt_tz.period_for_local(dt) }
343
+ assert_raises(AmbiguousTime) { t_tz.period_for_local(t) }
344
+ assert_raises(AmbiguousTime) { i_tz.period_for_local(i) }
345
345
  end
346
346
 
347
347
  def test_period_for_local_not_found
@@ -363,9 +363,9 @@ class TCTimezone < Test::Unit::TestCase
363
363
  t_tz = TestTimezone.new('America/New_York', nil, [], t)
364
364
  i_tz = TestTimezone.new('America/New_York', nil, [], i)
365
365
 
366
- assert_raise(PeriodNotFound) { dt_tz.period_for_local(dt) }
367
- assert_raise(PeriodNotFound) { t_tz.period_for_local(t) }
368
- assert_raise(PeriodNotFound) { i_tz.period_for_local(i) }
366
+ assert_raises(PeriodNotFound) { dt_tz.period_for_local(dt) }
367
+ assert_raises(PeriodNotFound) { t_tz.period_for_local(t) }
368
+ assert_raises(PeriodNotFound) { i_tz.period_for_local(i) }
369
369
  end
370
370
 
371
371
  def test_period_for_local_dst_flag_resolved
@@ -404,7 +404,7 @@ class TCTimezone < Test::Unit::TestCase
404
404
 
405
405
  tz = TestTimezone.new('America/New_York', nil, [p1, p2], dt)
406
406
 
407
- assert_raise(BlockCalled) {
407
+ assert_raises(BlockCalled) {
408
408
  tz.period_for_local(dt) {|periods|
409
409
  assert_equal([p1, p2], periods)
410
410
 
@@ -440,14 +440,14 @@ class TCTimezone < Test::Unit::TestCase
440
440
 
441
441
  tz = TestTimezone.new('Europe/Warsaw', nil, [p1, p2], dt)
442
442
 
443
- assert_raise(BlockCalled) {
443
+ assert_raises(BlockCalled) {
444
444
  tz.period_for_local(dt, true) {|periods|
445
445
  assert_equal([p1, p2], periods)
446
446
  raise BlockCalled, 'should be raised'
447
447
  }
448
448
  }
449
449
 
450
- assert_raise(BlockCalled) {
450
+ assert_raises(BlockCalled) {
451
451
  tz.period_for_local(dt, false) {|periods|
452
452
  assert_equal([p1, p2], periods)
453
453
  raise BlockCalled, 'should be raised'
@@ -470,19 +470,19 @@ class TCTimezone < Test::Unit::TestCase
470
470
 
471
471
  tz = TestTimezone.new('America/New_York', nil, [p1, p2], dt)
472
472
 
473
- assert_raise(AmbiguousTime) do
473
+ assert_raises(AmbiguousTime) do
474
474
  tz.period_for_local(dt) {|periods| nil}
475
475
  end
476
476
 
477
- assert_raise(AmbiguousTime) do
477
+ assert_raises(AmbiguousTime) do
478
478
  tz.period_for_local(dt) {|periods| periods}
479
479
  end
480
480
 
481
- assert_raise(AmbiguousTime) do
481
+ assert_raises(AmbiguousTime) do
482
482
  tz.period_for_local(dt) {|periods| []}
483
483
  end
484
484
 
485
- assert_raise(AmbiguousTime) do
485
+ assert_raises(AmbiguousTime) do
486
486
  tz.period_for_local(dt) {|periods| raise AmbiguousTime, 'Ambiguous time'}
487
487
  end
488
488
  end
@@ -574,15 +574,15 @@ class TCTimezone < Test::Unit::TestCase
574
574
  def test_local_to_utc_invalid
575
575
  dt = DateTime.new(2004,4,4,2,30,0)
576
576
  tz = TestTimezone.new('America/New_York', nil, [], dt)
577
- assert_raise(PeriodNotFound) { tz.local_to_utc(dt) }
577
+ assert_raises(PeriodNotFound) { tz.local_to_utc(dt) }
578
578
 
579
579
  t = Time.utc(2004,4,4,2,30,0)
580
580
  tz = TestTimezone.new('America/New_York', nil, [], t)
581
- assert_raise(PeriodNotFound) { tz.local_to_utc(t) }
581
+ assert_raises(PeriodNotFound) { tz.local_to_utc(t) }
582
582
 
583
583
  i = Time.utc(2004,4,4,2,30,0).to_i
584
584
  tz = TestTimezone.new('America/New_York', nil, [], i)
585
- assert_raise(PeriodNotFound) { tz.local_to_utc(i) }
585
+ assert_raises(PeriodNotFound) { tz.local_to_utc(i) }
586
586
  end
587
587
 
588
588
  def test_local_to_utc_ambiguous
@@ -598,15 +598,15 @@ class TCTimezone < Test::Unit::TestCase
598
598
 
599
599
  dt = DateTime.new(2004,10,31,1,30,0)
600
600
  tz = TestTimezone.new('America/New_York', nil, [p1, p2], dt)
601
- assert_raise(AmbiguousTime) { tz.local_to_utc(dt) }
601
+ assert_raises(AmbiguousTime) { tz.local_to_utc(dt) }
602
602
 
603
603
  t = Time.utc(2004,10,31,1,30,0)
604
604
  tz = TestTimezone.new('America/New_York', nil, [p1, p2], t)
605
- assert_raise(AmbiguousTime) { tz.local_to_utc(t) }
605
+ assert_raises(AmbiguousTime) { tz.local_to_utc(t) }
606
606
 
607
607
  i = Time.utc(2004,10,31,1,30,0).to_i
608
608
  tz = TestTimezone.new('America/New_York', nil, [p1, p2], i)
609
- assert_raise(AmbiguousTime) { tz.local_to_utc(i) }
609
+ assert_raises(AmbiguousTime) { tz.local_to_utc(i) }
610
610
  end
611
611
 
612
612
  def test_local_to_utc_not_found
@@ -628,9 +628,9 @@ class TCTimezone < Test::Unit::TestCase
628
628
  t_tz = TestTimezone.new('America/New_York', nil, [], t)
629
629
  i_tz = TestTimezone.new('America/New_York', nil, [], i)
630
630
 
631
- assert_raise(PeriodNotFound) { dt_tz.local_to_utc(dt) }
632
- assert_raise(PeriodNotFound) { t_tz.local_to_utc(t) }
633
- assert_raise(PeriodNotFound) { i_tz.local_to_utc(i) }
631
+ assert_raises(PeriodNotFound) { dt_tz.local_to_utc(dt) }
632
+ assert_raises(PeriodNotFound) { t_tz.local_to_utc(t) }
633
+ assert_raises(PeriodNotFound) { i_tz.local_to_utc(i) }
634
634
  end
635
635
 
636
636
  def test_local_to_utc_dst_flag_resolved
@@ -667,7 +667,7 @@ class TCTimezone < Test::Unit::TestCase
667
667
  dt = DateTime.new(2004,10,31,1,30,0)
668
668
  tz = TestTimezone.new('America/New_York', nil, [p1, p2], dt)
669
669
 
670
- assert_raise(BlockCalled) {
670
+ assert_raises(BlockCalled) {
671
671
  tz.local_to_utc(dt) {|periods|
672
672
  assert_equal([p1, p2], periods)
673
673
 
@@ -703,14 +703,14 @@ class TCTimezone < Test::Unit::TestCase
703
703
 
704
704
  tz = TestTimezone.new('Europe/Warsaw', nil, [p1, p2], dt)
705
705
 
706
- assert_raise(BlockCalled) do
706
+ assert_raises(BlockCalled) do
707
707
  tz.local_to_utc(dt, true) do |periods|
708
708
  assert_equal([p1, p2], periods)
709
709
  raise BlockCalled, 'should be raised'
710
710
  end
711
711
  end
712
712
 
713
- assert_raise(BlockCalled) do
713
+ assert_raises(BlockCalled) do
714
714
  tz.local_to_utc(dt, false) do |periods|
715
715
  assert_equal([p1, p2], periods)
716
716
  raise BlockCalled, 'should be raised'
@@ -740,10 +740,10 @@ class TCTimezone < Test::Unit::TestCase
740
740
  dt = DateTime.new(2004,10,31,1,30,0)
741
741
  tz = Timezone.get('America/New_York')
742
742
 
743
- assert_raise(AmbiguousTime) { tz.local_to_utc(dt) {|periods| nil} }
744
- assert_raise(AmbiguousTime) { tz.local_to_utc(dt) {|periods| periods} }
745
- assert_raise(AmbiguousTime) { tz.local_to_utc(dt) {|periods| []} }
746
- assert_raise(AmbiguousTime) { tz.local_to_utc(dt) {|periods| raise AmbiguousTime, 'Ambiguous time'} }
743
+ assert_raises(AmbiguousTime) { tz.local_to_utc(dt) {|periods| nil} }
744
+ assert_raises(AmbiguousTime) { tz.local_to_utc(dt) {|periods| periods} }
745
+ assert_raises(AmbiguousTime) { tz.local_to_utc(dt) {|periods| []} }
746
+ assert_raises(AmbiguousTime) { tz.local_to_utc(dt) {|periods| raise AmbiguousTime, 'Ambiguous time'} }
747
747
  end
748
748
 
749
749
  def test_now
@@ -24,8 +24,8 @@ class TCTimezoneLondon < Test::Unit::TestCase
24
24
  assert_equal(DateTime.new(2004,10,31,0,0,0), tz.local_to_utc(DateTime.new(2004,10,31,1,0,0), true))
25
25
  assert_equal(DateTime.new(2004,10,31,1,0,0), tz.local_to_utc(DateTime.new(2004,10,31,1,0,0), false))
26
26
 
27
- assert_raise(PeriodNotFound) { tz.local_to_utc(DateTime.new(2004,3,28,1,0,0)) }
28
- assert_raise(AmbiguousTime) { tz.local_to_utc(DateTime.new(2004,10,31,1,0,0)) }
27
+ assert_raises(PeriodNotFound) { tz.local_to_utc(DateTime.new(2004,3,28,1,0,0)) }
28
+ assert_raises(AmbiguousTime) { tz.local_to_utc(DateTime.new(2004,10,31,1,0,0)) }
29
29
 
30
30
  assert_equal(:GMT, tz.period_for_utc(DateTime.new(2004,3,28,0,59,59)).zone_identifier)
31
31
  assert_equal(:BST, tz.period_for_utc(DateTime.new(2004,3,28,1,0,0)).zone_identifier)
@@ -71,8 +71,8 @@ class TCTimezoneLondon < Test::Unit::TestCase
71
71
  assert_equal(DateTime.new(1961,10,29,1,0,0), tz.local_to_utc(DateTime.new(1961,10,29,2,0,0), true))
72
72
  assert_equal(DateTime.new(1961,10,29,2,0,0), tz.local_to_utc(DateTime.new(1961,10,29,2,0,0), false))
73
73
 
74
- assert_raise(PeriodNotFound) { tz.local_to_utc(DateTime.new(1961,3,26,2,0,0)) }
75
- assert_raise(AmbiguousTime) { tz.local_to_utc(DateTime.new(1961,10,29,2,0,0)) }
74
+ assert_raises(PeriodNotFound) { tz.local_to_utc(DateTime.new(1961,3,26,2,0,0)) }
75
+ assert_raises(AmbiguousTime) { tz.local_to_utc(DateTime.new(1961,10,29,2,0,0)) }
76
76
 
77
77
  assert_equal(:GMT, tz.period_for_utc(DateTime.new(1961,3,26,1,59,59)).zone_identifier)
78
78
  assert_equal(:BST, tz.period_for_utc(DateTime.new(1961,3,26,2,0,0)).zone_identifier)
@@ -24,8 +24,8 @@ class TCTimezoneMelbourne < Test::Unit::TestCase
24
24
  assert_equal(DateTime.new(2004,10,30,15,59,59), tz.local_to_utc(DateTime.new(2004,10,31,1,59,59)))
25
25
  assert_equal(DateTime.new(2004,10,30,16,0,0), tz.local_to_utc(DateTime.new(2004,10,31,3,0,0)))
26
26
 
27
- assert_raise(PeriodNotFound) { tz.local_to_utc(DateTime.new(2004,10,31,2,0,0)) }
28
- assert_raise(AmbiguousTime) { tz.local_to_utc(DateTime.new(2004,3,28,2,0,0)) }
27
+ assert_raises(PeriodNotFound) { tz.local_to_utc(DateTime.new(2004,10,31,2,0,0)) }
28
+ assert_raises(AmbiguousTime) { tz.local_to_utc(DateTime.new(2004,3,28,2,0,0)) }
29
29
 
30
30
  assert_equal(:EST, tz.period_for_utc(DateTime.new(2004,3,27,15,59,59)).zone_identifier)
31
31
  assert_equal(:EST, tz.period_for_utc(DateTime.new(2004,3,27,16,0,0)).zone_identifier)
@@ -71,8 +71,8 @@ class TCTimezoneMelbourne < Test::Unit::TestCase
71
71
  assert_equal(DateTime.new(1942,9,26,15,59,59), tz.local_to_utc(DateTime.new(1942,9,27,1,59,59)))
72
72
  assert_equal(DateTime.new(1942,9,26,16,0,0), tz.local_to_utc(DateTime.new(1942,9,27,3,0,0)))
73
73
 
74
- assert_raise(PeriodNotFound) { tz.local_to_utc(DateTime.new(1942,9,27,2,0,0)) }
75
- assert_raise(AmbiguousTime) { tz.local_to_utc(DateTime.new(1942,3,29,1,0,0)) }
74
+ assert_raises(PeriodNotFound) { tz.local_to_utc(DateTime.new(1942,9,27,2,0,0)) }
75
+ assert_raises(AmbiguousTime) { tz.local_to_utc(DateTime.new(1942,3,29,1,0,0)) }
76
76
 
77
77
  assert_equal(:EST, tz.period_for_utc(DateTime.new(1942,3,28,14,59,59)).zone_identifier)
78
78
  assert_equal(:EST, tz.period_for_utc(DateTime.new(1942,3,28,15,0,0)).zone_identifier)
@@ -24,8 +24,8 @@ class TCTimezoneNewYork < Test::Unit::TestCase
24
24
  assert_equal(DateTime.new(2004,10,31,5,0,0), tz.local_to_utc(DateTime.new(2004,10,31,1,0,0), true))
25
25
  assert_equal(DateTime.new(2004,10,31,6,0,0), tz.local_to_utc(DateTime.new(2004,10,31,1,0,0), false))
26
26
 
27
- assert_raise(PeriodNotFound) { tz.local_to_utc(DateTime.new(2004,4,4,2,0,0)) }
28
- assert_raise(AmbiguousTime) { tz.local_to_utc(DateTime.new(2004,10,31,1,0,0)) }
27
+ assert_raises(PeriodNotFound) { tz.local_to_utc(DateTime.new(2004,4,4,2,0,0)) }
28
+ assert_raises(AmbiguousTime) { tz.local_to_utc(DateTime.new(2004,10,31,1,0,0)) }
29
29
 
30
30
  assert_equal(:EST, tz.period_for_utc(DateTime.new(2004,4,4,6,59,59)).zone_identifier)
31
31
  assert_equal(:EDT, tz.period_for_utc(DateTime.new(2004,4,4,7,0,0)).zone_identifier)
@@ -71,8 +71,8 @@ class TCTimezoneNewYork < Test::Unit::TestCase
71
71
  assert_equal(DateTime.new(1957,10,27,5,0,0), tz.local_to_utc(DateTime.new(1957,10,27,1,0,0), true))
72
72
  assert_equal(DateTime.new(1957,10,27,6,0,0), tz.local_to_utc(DateTime.new(1957,10,27,1,0,0), false))
73
73
 
74
- assert_raise(PeriodNotFound) { tz.local_to_utc(DateTime.new(1957,4,28,2,0,0)) }
75
- assert_raise(AmbiguousTime) { tz.local_to_utc(DateTime.new(1957,10,27,1,0,0)) }
74
+ assert_raises(PeriodNotFound) { tz.local_to_utc(DateTime.new(1957,4,28,2,0,0)) }
75
+ assert_raises(AmbiguousTime) { tz.local_to_utc(DateTime.new(1957,10,27,1,0,0)) }
76
76
 
77
77
  assert_equal(:EST, tz.period_for_utc(DateTime.new(1957,4,28,6,59,59)).zone_identifier)
78
78
  assert_equal(:EDT, tz.period_for_utc(DateTime.new(1957,4,28,7,0,0)).zone_identifier)
@@ -38,7 +38,7 @@ class TCTimezonePeriod < Test::Unit::TestCase
38
38
  start_t = TimezoneTransitionInfo.new(dst, std, 1136073600)
39
39
  end_t = TimezoneTransitionInfo.new(std, dst, 1136160000)
40
40
 
41
- assert_raise(ArgumentError) { TimezonePeriod.new(start_t, end_t, special) }
41
+ assert_raises(ArgumentError) { TimezonePeriod.new(start_t, end_t, special) }
42
42
  end
43
43
 
44
44
  def test_initialize_start
@@ -69,7 +69,7 @@ class TCTimezonePeriod < Test::Unit::TestCase
69
69
  special = TimezoneOffsetInfo.new(0, 0, :SPECIAL)
70
70
  start_t = TimezoneTransitionInfo.new(dst, std, 1136073600)
71
71
 
72
- assert_raise(ArgumentError) { TimezonePeriod.new(start_t, nil, special) }
72
+ assert_raises(ArgumentError) { TimezonePeriod.new(start_t, nil, special) }
73
73
  end
74
74
 
75
75
  def test_initialize_end
@@ -100,11 +100,11 @@ class TCTimezonePeriod < Test::Unit::TestCase
100
100
  special = TimezoneOffsetInfo.new(0, 0, :SPECIAL)
101
101
  end_t = TimezoneTransitionInfo.new(std, dst, 1136160000)
102
102
 
103
- assert_raise(ArgumentError) { TimezonePeriod.new(nil, end_t, special) }
103
+ assert_raises(ArgumentError) { TimezonePeriod.new(nil, end_t, special) }
104
104
  end
105
105
 
106
106
  def test_initialize
107
- assert_raise(ArgumentError) { TimezonePeriod.new(nil, nil) }
107
+ assert_raises(ArgumentError) { TimezonePeriod.new(nil, nil) }
108
108
  end
109
109
 
110
110
  def test_initialize_offset
@@ -8,24 +8,25 @@ class TCTimezoneProxy < Test::Unit::TestCase
8
8
  def test_not_exist
9
9
  proxy = TimezoneProxy.new('Nothing/Special')
10
10
  assert_equal('Nothing/Special', proxy.identifier)
11
- assert_raise(InvalidTimezoneIdentifier) { proxy.now }
12
- assert_raise(InvalidTimezoneIdentifier) { proxy.current_period }
13
- assert_raise(InvalidTimezoneIdentifier) { proxy.current_period_and_time }
14
- assert_raise(InvalidTimezoneIdentifier) { proxy.current_time_and_period }
15
- assert_raise(InvalidTimezoneIdentifier) { proxy.utc_to_local(DateTime.new(2006,1,1,0,0,0)) }
16
- assert_raise(InvalidTimezoneIdentifier) { proxy.local_to_utc(DateTime.new(2006,1,1,0,0,0)) }
17
- assert_raise(InvalidTimezoneIdentifier) { proxy.period_for_utc(DateTime.new(2006,1,1,0,0,0)) }
18
- assert_raise(InvalidTimezoneIdentifier) { proxy.period_for_local(DateTime.new(2006,1,1,0,0,0)) }
11
+ assert_raises(InvalidTimezoneIdentifier) { proxy.now }
12
+ assert_raises(InvalidTimezoneIdentifier) { proxy.current_period }
13
+ assert_raises(InvalidTimezoneIdentifier) { proxy.current_period_and_time }
14
+ assert_raises(InvalidTimezoneIdentifier) { proxy.current_time_and_period }
15
+ assert_raises(InvalidTimezoneIdentifier) { proxy.utc_to_local(DateTime.new(2006,1,1,0,0,0)) }
16
+ assert_raises(InvalidTimezoneIdentifier) { proxy.local_to_utc(DateTime.new(2006,1,1,0,0,0)) }
17
+ assert_raises(InvalidTimezoneIdentifier) { proxy.period_for_utc(DateTime.new(2006,1,1,0,0,0)) }
18
+ assert_raises(InvalidTimezoneIdentifier) { proxy.period_for_local(DateTime.new(2006,1,1,0,0,0)) }
19
19
  end
20
20
 
21
21
  def test_valid
22
22
  proxy = TimezoneProxy.new('Europe/London')
23
23
  assert_equal('Europe/London', proxy.identifier)
24
24
 
25
- assert_nothing_raised { proxy.now }
26
- assert_nothing_raised { proxy.current_period }
27
- assert_nothing_raised { proxy.current_period_and_time }
28
- assert_nothing_raised { proxy.current_time_and_period }
25
+ # Test nothing raised
26
+ proxy.now
27
+ proxy.current_period
28
+ proxy.current_period_and_time
29
+ proxy.current_time_and_period
29
30
 
30
31
  real = Timezone.get('Europe/London')
31
32
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tzinfo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.10
4
+ version: 0.3.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Philip Ross
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-09-16 00:00:00 +01:00
12
+ date: 2008-10-07 00:00:00 +01:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -626,6 +626,7 @@ files:
626
626
  - lib/tzinfo/linked_timezone.rb
627
627
  - lib/tzinfo/linked_timezone_info.rb
628
628
  - lib/tzinfo/offset_rationals.rb
629
+ - lib/tzinfo/ruby_core_support.rb
629
630
  - lib/tzinfo/timezone.rb
630
631
  - lib/tzinfo/timezone_definition.rb
631
632
  - lib/tzinfo/timezone_index_definition.rb
@@ -647,6 +648,7 @@ files:
647
648
  - test/tc_linked_timezone.rb
648
649
  - test/tc_linked_timezone_info.rb
649
650
  - test/tc_offset_rationals.rb
651
+ - test/tc_ruby_core_support.rb
650
652
  - test/tc_timezone.rb
651
653
  - test/tc_timezone_definition.rb
652
654
  - test/tc_timezone_index_definition.rb