tzinfo 0.2.0 → 0.2.1
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 +25 -0
- data/Rakefile +1 -1
- data/lib/tzinfo/definitions/America/Dawson.rb +89 -89
- data/lib/tzinfo/definitions/America/Goose_Bay.rb +89 -89
- data/lib/tzinfo/definitions/America/Inuvik.rb +89 -89
- data/lib/tzinfo/definitions/America/Port__m__au__m__Prince.rb +91 -1
- data/lib/tzinfo/definitions/America/St_Johns.rb +89 -89
- data/lib/tzinfo/definitions/America/Vancouver.rb +89 -89
- data/lib/tzinfo/definitions/America/Whitehorse.rb +89 -89
- data/lib/tzinfo/definitions/America/Winnipeg.rb +132 -132
- data/lib/tzinfo/definitions/America/Yellowknife.rb +89 -89
- data/lib/tzinfo/definitions/Asia/Colombo.rb +2 -2
- data/lib/tzinfo/time_or_datetime.rb +15 -3
- data/lib/tzinfo/timezone_period.rb +2 -1
- data/lib/tzinfo/timezone_period_list.rb +9 -8
- data/lib/tzinfo/tzdataparser.rb +1 -1
- data/test/tc_time_or_datetime.rb +8 -2
- data/test/tc_timezone.rb +45 -3
- data/test/tc_timezone_period.rb +7 -3
- data/test/tc_timezone_period_list.rb +12 -0
- metadata +852 -845
@@ -69,95 +69,95 @@ add_period(2004,10) {TimezonePeriod.new(1099209600,1112518800,-25200,0,:MST)}
|
|
69
69
|
add_period(2005,4) {TimezonePeriod.new(1112518800,1130659200,-25200,3600,:MDT)}
|
70
70
|
add_period(2005,10) {TimezonePeriod.new(1130659200,1143968400,-25200,0,:MST)}
|
71
71
|
add_period(2006,4) {TimezonePeriod.new(1143968400,1162108800,-25200,3600,:MDT)}
|
72
|
-
add_period(2006,10) {TimezonePeriod.new(1162108800,
|
73
|
-
add_period(2007,
|
74
|
-
add_period(2007,
|
75
|
-
add_period(2008,
|
76
|
-
add_period(2008,
|
77
|
-
add_period(2009,
|
78
|
-
add_period(2009,
|
79
|
-
add_period(2010,
|
80
|
-
add_period(2010,
|
81
|
-
add_period(2011,
|
82
|
-
add_period(2011,
|
83
|
-
add_period(2012,
|
84
|
-
add_period(2012,
|
85
|
-
add_period(2013,
|
86
|
-
add_period(2013,
|
87
|
-
add_period(2014,
|
88
|
-
add_period(2014,
|
89
|
-
add_period(2015,
|
90
|
-
add_period(2015,
|
91
|
-
add_period(2016,
|
92
|
-
add_period(2016,
|
93
|
-
add_period(2017,
|
94
|
-
add_period(2017,
|
95
|
-
add_period(2018,
|
96
|
-
add_period(2018,
|
97
|
-
add_period(2019,
|
98
|
-
add_period(2019,
|
99
|
-
add_period(2020,
|
100
|
-
add_period(2020,
|
101
|
-
add_period(2021,
|
102
|
-
add_period(2021,
|
103
|
-
add_period(2022,
|
104
|
-
add_period(2022,
|
105
|
-
add_period(2023,
|
106
|
-
add_period(2023,
|
107
|
-
add_period(2024,
|
108
|
-
add_period(2024,
|
109
|
-
add_period(2025,
|
110
|
-
add_period(2025,
|
111
|
-
add_period(2026,
|
112
|
-
add_period(2026,
|
113
|
-
add_period(2027,
|
114
|
-
add_period(2027,
|
115
|
-
add_period(2028,
|
116
|
-
add_period(2028,
|
117
|
-
add_period(2029,
|
118
|
-
add_period(2029,
|
119
|
-
add_period(2030,
|
120
|
-
add_period(2030,
|
121
|
-
add_period(2031,
|
122
|
-
add_period(2031,
|
123
|
-
add_period(2032,
|
124
|
-
add_period(2032,
|
125
|
-
add_period(2033,
|
126
|
-
add_period(2033,
|
127
|
-
add_period(2034,
|
128
|
-
add_period(2034,
|
129
|
-
add_period(2035,
|
130
|
-
add_period(2035,
|
131
|
-
add_period(2036,
|
132
|
-
add_period(2036,
|
133
|
-
add_period(2037,
|
134
|
-
add_period(2037,
|
135
|
-
add_period(2038,
|
136
|
-
add_period(2038,
|
137
|
-
add_period(2039,
|
138
|
-
add_period(2039,
|
139
|
-
add_period(2040,
|
140
|
-
add_period(2040,
|
141
|
-
add_period(2041,
|
142
|
-
add_period(2041,
|
143
|
-
add_period(2042,
|
144
|
-
add_period(2042,
|
145
|
-
add_period(2043,
|
146
|
-
add_period(2043,
|
147
|
-
add_period(2044,
|
148
|
-
add_period(2044,
|
149
|
-
add_period(2045,
|
150
|
-
add_period(2045,
|
151
|
-
add_period(2046,
|
152
|
-
add_period(2046,
|
153
|
-
add_period(2047,
|
154
|
-
add_period(2047,
|
155
|
-
add_period(2048,
|
156
|
-
add_period(2048,
|
157
|
-
add_period(2049,
|
158
|
-
add_period(2049,
|
159
|
-
add_period(2050,
|
160
|
-
add_period(2050,
|
72
|
+
add_period(2006,10) {TimezonePeriod.new(1162108800,1173603600,-25200,0,:MST)}
|
73
|
+
add_period(2007,3) {TimezonePeriod.new(1173603600,1194163200,-25200,3600,:MDT)}
|
74
|
+
add_period(2007,11) {TimezonePeriod.new(1194163200,1205053200,-25200,0,:MST)}
|
75
|
+
add_period(2008,3) {TimezonePeriod.new(1205053200,1225612800,-25200,3600,:MDT)}
|
76
|
+
add_period(2008,11) {TimezonePeriod.new(1225612800,1236502800,-25200,0,:MST)}
|
77
|
+
add_period(2009,3) {TimezonePeriod.new(1236502800,1257062400,-25200,3600,:MDT)}
|
78
|
+
add_period(2009,11) {TimezonePeriod.new(1257062400,1268557200,-25200,0,:MST)}
|
79
|
+
add_period(2010,3) {TimezonePeriod.new(1268557200,1289116800,-25200,3600,:MDT)}
|
80
|
+
add_period(2010,11) {TimezonePeriod.new(1289116800,1300006800,-25200,0,:MST)}
|
81
|
+
add_period(2011,3) {TimezonePeriod.new(1300006800,1320566400,-25200,3600,:MDT)}
|
82
|
+
add_period(2011,11) {TimezonePeriod.new(1320566400,1331456400,-25200,0,:MST)}
|
83
|
+
add_period(2012,3) {TimezonePeriod.new(1331456400,1352016000,-25200,3600,:MDT)}
|
84
|
+
add_period(2012,11) {TimezonePeriod.new(1352016000,1362906000,-25200,0,:MST)}
|
85
|
+
add_period(2013,3) {TimezonePeriod.new(1362906000,1383465600,-25200,3600,:MDT)}
|
86
|
+
add_period(2013,11) {TimezonePeriod.new(1383465600,1394355600,-25200,0,:MST)}
|
87
|
+
add_period(2014,3) {TimezonePeriod.new(1394355600,1414915200,-25200,3600,:MDT)}
|
88
|
+
add_period(2014,11) {TimezonePeriod.new(1414915200,1425805200,-25200,0,:MST)}
|
89
|
+
add_period(2015,3) {TimezonePeriod.new(1425805200,1446364800,-25200,3600,:MDT)}
|
90
|
+
add_period(2015,11) {TimezonePeriod.new(1446364800,1457859600,-25200,0,:MST)}
|
91
|
+
add_period(2016,3) {TimezonePeriod.new(1457859600,1478419200,-25200,3600,:MDT)}
|
92
|
+
add_period(2016,11) {TimezonePeriod.new(1478419200,1489309200,-25200,0,:MST)}
|
93
|
+
add_period(2017,3) {TimezonePeriod.new(1489309200,1509868800,-25200,3600,:MDT)}
|
94
|
+
add_period(2017,11) {TimezonePeriod.new(1509868800,1520758800,-25200,0,:MST)}
|
95
|
+
add_period(2018,3) {TimezonePeriod.new(1520758800,1541318400,-25200,3600,:MDT)}
|
96
|
+
add_period(2018,11) {TimezonePeriod.new(1541318400,1552208400,-25200,0,:MST)}
|
97
|
+
add_period(2019,3) {TimezonePeriod.new(1552208400,1572768000,-25200,3600,:MDT)}
|
98
|
+
add_period(2019,11) {TimezonePeriod.new(1572768000,1583658000,-25200,0,:MST)}
|
99
|
+
add_period(2020,3) {TimezonePeriod.new(1583658000,1604217600,-25200,3600,:MDT)}
|
100
|
+
add_period(2020,11) {TimezonePeriod.new(1604217600,1615712400,-25200,0,:MST)}
|
101
|
+
add_period(2021,3) {TimezonePeriod.new(1615712400,1636272000,-25200,3600,:MDT)}
|
102
|
+
add_period(2021,11) {TimezonePeriod.new(1636272000,1647162000,-25200,0,:MST)}
|
103
|
+
add_period(2022,3) {TimezonePeriod.new(1647162000,1667721600,-25200,3600,:MDT)}
|
104
|
+
add_period(2022,11) {TimezonePeriod.new(1667721600,1678611600,-25200,0,:MST)}
|
105
|
+
add_period(2023,3) {TimezonePeriod.new(1678611600,1699171200,-25200,3600,:MDT)}
|
106
|
+
add_period(2023,11) {TimezonePeriod.new(1699171200,1710061200,-25200,0,:MST)}
|
107
|
+
add_period(2024,3) {TimezonePeriod.new(1710061200,1730620800,-25200,3600,:MDT)}
|
108
|
+
add_period(2024,11) {TimezonePeriod.new(1730620800,1741510800,-25200,0,:MST)}
|
109
|
+
add_period(2025,3) {TimezonePeriod.new(1741510800,1762070400,-25200,3600,:MDT)}
|
110
|
+
add_period(2025,11) {TimezonePeriod.new(1762070400,1772960400,-25200,0,:MST)}
|
111
|
+
add_period(2026,3) {TimezonePeriod.new(1772960400,1793520000,-25200,3600,:MDT)}
|
112
|
+
add_period(2026,11) {TimezonePeriod.new(1793520000,1805014800,-25200,0,:MST)}
|
113
|
+
add_period(2027,3) {TimezonePeriod.new(1805014800,1825574400,-25200,3600,:MDT)}
|
114
|
+
add_period(2027,11) {TimezonePeriod.new(1825574400,1836464400,-25200,0,:MST)}
|
115
|
+
add_period(2028,3) {TimezonePeriod.new(1836464400,1857024000,-25200,3600,:MDT)}
|
116
|
+
add_period(2028,11) {TimezonePeriod.new(1857024000,1867914000,-25200,0,:MST)}
|
117
|
+
add_period(2029,3) {TimezonePeriod.new(1867914000,1888473600,-25200,3600,:MDT)}
|
118
|
+
add_period(2029,11) {TimezonePeriod.new(1888473600,1899363600,-25200,0,:MST)}
|
119
|
+
add_period(2030,3) {TimezonePeriod.new(1899363600,1919923200,-25200,3600,:MDT)}
|
120
|
+
add_period(2030,11) {TimezonePeriod.new(1919923200,1930813200,-25200,0,:MST)}
|
121
|
+
add_period(2031,3) {TimezonePeriod.new(1930813200,1951372800,-25200,3600,:MDT)}
|
122
|
+
add_period(2031,11) {TimezonePeriod.new(1951372800,1962867600,-25200,0,:MST)}
|
123
|
+
add_period(2032,3) {TimezonePeriod.new(1962867600,1983427200,-25200,3600,:MDT)}
|
124
|
+
add_period(2032,11) {TimezonePeriod.new(1983427200,1994317200,-25200,0,:MST)}
|
125
|
+
add_period(2033,3) {TimezonePeriod.new(1994317200,2014876800,-25200,3600,:MDT)}
|
126
|
+
add_period(2033,11) {TimezonePeriod.new(2014876800,2025766800,-25200,0,:MST)}
|
127
|
+
add_period(2034,3) {TimezonePeriod.new(2025766800,2046326400,-25200,3600,:MDT)}
|
128
|
+
add_period(2034,11) {TimezonePeriod.new(2046326400,2057216400,-25200,0,:MST)}
|
129
|
+
add_period(2035,3) {TimezonePeriod.new(2057216400,2077776000,-25200,3600,:MDT)}
|
130
|
+
add_period(2035,11) {TimezonePeriod.new(2077776000,2088666000,-25200,0,:MST)}
|
131
|
+
add_period(2036,3) {TimezonePeriod.new(2088666000,2109225600,-25200,3600,:MDT)}
|
132
|
+
add_period(2036,11) {TimezonePeriod.new(2109225600,2120115600,-25200,0,:MST)}
|
133
|
+
add_period(2037,3) {TimezonePeriod.new(2120115600,2140675200,-25200,3600,:MDT)}
|
134
|
+
add_period(2037,11) {TimezonePeriod.new(2140675200,DateTime.new0(Rational.new!(19723975,8),0,Date::ITALY),-25200,0,:MST)}
|
135
|
+
add_period(2038,3) {TimezonePeriod.new(DateTime.new0(Rational.new!(19723975,8),0,Date::ITALY),DateTime.new0(Rational.new!(14794409,6),0,Date::ITALY),-25200,3600,:MDT)}
|
136
|
+
add_period(2038,11) {TimezonePeriod.new(DateTime.new0(Rational.new!(14794409,6),0,Date::ITALY),DateTime.new0(Rational.new!(19726887,8),0,Date::ITALY),-25200,0,:MST)}
|
137
|
+
add_period(2039,3) {TimezonePeriod.new(DateTime.new0(Rational.new!(19726887,8),0,Date::ITALY),DateTime.new0(Rational.new!(14796593,6),0,Date::ITALY),-25200,3600,:MDT)}
|
138
|
+
add_period(2039,11) {TimezonePeriod.new(DateTime.new0(Rational.new!(14796593,6),0,Date::ITALY),DateTime.new0(Rational.new!(19729799,8),0,Date::ITALY),-25200,0,:MST)}
|
139
|
+
add_period(2040,3) {TimezonePeriod.new(DateTime.new0(Rational.new!(19729799,8),0,Date::ITALY),DateTime.new0(Rational.new!(14798777,6),0,Date::ITALY),-25200,3600,:MDT)}
|
140
|
+
add_period(2040,11) {TimezonePeriod.new(DateTime.new0(Rational.new!(14798777,6),0,Date::ITALY),DateTime.new0(Rational.new!(19732711,8),0,Date::ITALY),-25200,0,:MST)}
|
141
|
+
add_period(2041,3) {TimezonePeriod.new(DateTime.new0(Rational.new!(19732711,8),0,Date::ITALY),DateTime.new0(Rational.new!(14800961,6),0,Date::ITALY),-25200,3600,:MDT)}
|
142
|
+
add_period(2041,11) {TimezonePeriod.new(DateTime.new0(Rational.new!(14800961,6),0,Date::ITALY),DateTime.new0(Rational.new!(19735623,8),0,Date::ITALY),-25200,0,:MST)}
|
143
|
+
add_period(2042,3) {TimezonePeriod.new(DateTime.new0(Rational.new!(19735623,8),0,Date::ITALY),DateTime.new0(Rational.new!(14803145,6),0,Date::ITALY),-25200,3600,:MDT)}
|
144
|
+
add_period(2042,11) {TimezonePeriod.new(DateTime.new0(Rational.new!(14803145,6),0,Date::ITALY),DateTime.new0(Rational.new!(19738535,8),0,Date::ITALY),-25200,0,:MST)}
|
145
|
+
add_period(2043,3) {TimezonePeriod.new(DateTime.new0(Rational.new!(19738535,8),0,Date::ITALY),DateTime.new0(Rational.new!(14805329,6),0,Date::ITALY),-25200,3600,:MDT)}
|
146
|
+
add_period(2043,11) {TimezonePeriod.new(DateTime.new0(Rational.new!(14805329,6),0,Date::ITALY),DateTime.new0(Rational.new!(19741503,8),0,Date::ITALY),-25200,0,:MST)}
|
147
|
+
add_period(2044,3) {TimezonePeriod.new(DateTime.new0(Rational.new!(19741503,8),0,Date::ITALY),DateTime.new0(Rational.new!(14807555,6),0,Date::ITALY),-25200,3600,:MDT)}
|
148
|
+
add_period(2044,11) {TimezonePeriod.new(DateTime.new0(Rational.new!(14807555,6),0,Date::ITALY),DateTime.new0(Rational.new!(19744415,8),0,Date::ITALY),-25200,0,:MST)}
|
149
|
+
add_period(2045,3) {TimezonePeriod.new(DateTime.new0(Rational.new!(19744415,8),0,Date::ITALY),DateTime.new0(Rational.new!(14809739,6),0,Date::ITALY),-25200,3600,:MDT)}
|
150
|
+
add_period(2045,11) {TimezonePeriod.new(DateTime.new0(Rational.new!(14809739,6),0,Date::ITALY),DateTime.new0(Rational.new!(19747327,8),0,Date::ITALY),-25200,0,:MST)}
|
151
|
+
add_period(2046,3) {TimezonePeriod.new(DateTime.new0(Rational.new!(19747327,8),0,Date::ITALY),DateTime.new0(Rational.new!(14811923,6),0,Date::ITALY),-25200,3600,:MDT)}
|
152
|
+
add_period(2046,11) {TimezonePeriod.new(DateTime.new0(Rational.new!(14811923,6),0,Date::ITALY),DateTime.new0(Rational.new!(19750239,8),0,Date::ITALY),-25200,0,:MST)}
|
153
|
+
add_period(2047,3) {TimezonePeriod.new(DateTime.new0(Rational.new!(19750239,8),0,Date::ITALY),DateTime.new0(Rational.new!(14814107,6),0,Date::ITALY),-25200,3600,:MDT)}
|
154
|
+
add_period(2047,11) {TimezonePeriod.new(DateTime.new0(Rational.new!(14814107,6),0,Date::ITALY),DateTime.new0(Rational.new!(19753151,8),0,Date::ITALY),-25200,0,:MST)}
|
155
|
+
add_period(2048,3) {TimezonePeriod.new(DateTime.new0(Rational.new!(19753151,8),0,Date::ITALY),DateTime.new0(Rational.new!(14816291,6),0,Date::ITALY),-25200,3600,:MDT)}
|
156
|
+
add_period(2048,11) {TimezonePeriod.new(DateTime.new0(Rational.new!(14816291,6),0,Date::ITALY),DateTime.new0(Rational.new!(19756119,8),0,Date::ITALY),-25200,0,:MST)}
|
157
|
+
add_period(2049,3) {TimezonePeriod.new(DateTime.new0(Rational.new!(19756119,8),0,Date::ITALY),DateTime.new0(Rational.new!(14818517,6),0,Date::ITALY),-25200,3600,:MDT)}
|
158
|
+
add_period(2049,11) {TimezonePeriod.new(DateTime.new0(Rational.new!(14818517,6),0,Date::ITALY),DateTime.new0(Rational.new!(19759031,8),0,Date::ITALY),-25200,0,:MST)}
|
159
|
+
add_period(2050,3) {TimezonePeriod.new(DateTime.new0(Rational.new!(19759031,8),0,Date::ITALY),DateTime.new0(Rational.new!(14820701,6),0,Date::ITALY),-25200,3600,:MDT)}
|
160
|
+
add_period(2050,11) {TimezonePeriod.new(DateTime.new0(Rational.new!(14820701,6),0,Date::ITALY),nil,-25200,0,:MST)}
|
161
161
|
end
|
162
162
|
end
|
163
163
|
end
|
@@ -12,8 +12,8 @@ add_period(1942,1) {TimezonePeriod.new(DateTime.new0(Rational.new!(116657485,48)
|
|
12
12
|
add_period(1942,8) {TimezonePeriod.new(DateTime.new0(Rational.new!(9722413,4),0,Date::ITALY),DateTime.new0(Rational.new!(38907909,16),0,Date::ITALY),19800,3600,:IST)}
|
13
13
|
add_period(1945,10) {TimezonePeriod.new(DateTime.new0(Rational.new!(38907909,16),0,Date::ITALY),832962600,19800,0,:IST)}
|
14
14
|
add_period(1996,5) {TimezonePeriod.new(832962600,846266400,23400,0,:LKT)}
|
15
|
-
add_period(1996,10) {TimezonePeriod.new(846266400,
|
16
|
-
add_period(2006,4) {TimezonePeriod.new(
|
15
|
+
add_period(1996,10) {TimezonePeriod.new(846266400,1145039400,21600,0,:LKT)}
|
16
|
+
add_period(2006,4) {TimezonePeriod.new(1145039400,nil,19800,0,:IST)}
|
17
17
|
end
|
18
18
|
end
|
19
19
|
end
|
@@ -31,7 +31,8 @@ module TZInfo
|
|
31
31
|
include Comparable
|
32
32
|
|
33
33
|
# Constructs a new TimeOrDateTime. timeOrDateTime can be a Time, DateTime
|
34
|
-
# or an integer. If using a Time, any time zone information is
|
34
|
+
# or an integer. If using a Time or DateTime, any time zone information is
|
35
|
+
# ignored.
|
35
36
|
def initialize(timeOrDateTime)
|
36
37
|
@time = nil
|
37
38
|
@datetime = nil
|
@@ -43,6 +44,7 @@ module TZInfo
|
|
43
44
|
@orig = @time
|
44
45
|
elsif timeOrDateTime.is_a?(DateTime)
|
45
46
|
@datetime = timeOrDateTime
|
47
|
+
@datetime = @datetime.new_offset(0) unless @datetime.offset == 0
|
46
48
|
@orig = @datetime
|
47
49
|
else
|
48
50
|
@timestamp = timeOrDateTime.to_i
|
@@ -171,8 +173,18 @@ module TZInfo
|
|
171
173
|
#
|
172
174
|
# Milliseconds and smaller units are ignored in the comparison.
|
173
175
|
def <=>(timeOrDateTime)
|
174
|
-
if timeOrDateTime.is_a?(TimeOrDateTime)
|
175
|
-
|
176
|
+
if timeOrDateTime.is_a?(TimeOrDateTime)
|
177
|
+
orig = timeOrDateTime.to_orig
|
178
|
+
|
179
|
+
if @orig.is_a?(DateTime) || orig.is_a?(DateTime)
|
180
|
+
# If either is a DateTime, assume it is there for a reason
|
181
|
+
# (i.e. for range).
|
182
|
+
to_datetime <=> timeOrDateTime.to_datetime
|
183
|
+
elsif orig.is_a?(Time)
|
184
|
+
to_time <=> timeOrDateTime.to_time
|
185
|
+
else
|
186
|
+
to_i <=> timeOrDateTime.to_i
|
187
|
+
end
|
176
188
|
elsif @orig.is_a?(DateTime) || timeOrDateTime.is_a?(DateTime)
|
177
189
|
# If either is a DateTime, assume it is there for a reason
|
178
190
|
# (i.e. for range).
|
@@ -41,7 +41,8 @@ module TZInfo
|
|
41
41
|
# The identifier of this period, e.g. "GMT" (Greenwich Mean Time) or "BST"
|
42
42
|
# (British Summer Time) for "Europe/London". The returned identifier is a
|
43
43
|
# symbol.
|
44
|
-
attr_reader :zone_identifier
|
44
|
+
attr_reader :zone_identifier
|
45
|
+
alias :abbreviation :zone_identifier
|
45
46
|
|
46
47
|
# Total offset from UTC (seconds). Equal to utc_offset + std_offset.
|
47
48
|
attr_reader :utc_total_offset
|
@@ -157,14 +157,15 @@ module TZInfo
|
|
157
157
|
result << contents[j]
|
158
158
|
found_first = i if found_first.nil?
|
159
159
|
end
|
160
|
-
}
|
161
|
-
|
162
|
-
if !found_first.nil? && i < found_first
|
163
|
-
# searched far enough
|
164
|
-
break
|
165
|
-
end
|
160
|
+
}
|
166
161
|
elsif !contents.nil? && contents.valid_for_local?(local)
|
167
|
-
result << contents
|
162
|
+
result << contents
|
163
|
+
found_first = i if found_first.nil?
|
164
|
+
end
|
165
|
+
|
166
|
+
if !contents.nil? && !found_first.nil? && i < found_first
|
167
|
+
# searched far enough
|
168
|
+
break
|
168
169
|
end
|
169
170
|
}
|
170
171
|
end
|
@@ -191,7 +192,7 @@ module TZInfo
|
|
191
192
|
index
|
192
193
|
end
|
193
194
|
|
194
|
-
# Returns the contents of any 6 month period,
|
195
|
+
# Returns the contents of any 6 month period, expanding any blocks to
|
195
196
|
# TimezonePeriods first.
|
196
197
|
def get_contents(index)
|
197
198
|
contents = @list[index]
|
data/lib/tzinfo/tzdataparser.rb
CHANGED
data/test/tc_time_or_datetime.rb
CHANGED
@@ -9,12 +9,18 @@ class TCTimeOrDateTime < Test::Unit::TestCase
|
|
9
9
|
TimeOrDateTime.new(Time.utc(2006, 3, 24, 15, 32, 3))
|
10
10
|
end
|
11
11
|
|
12
|
-
def test_initialize_time_local
|
13
|
-
tdt = TimeOrDateTime.new(Time.local(2006, 3, 24, 15, 32, 3))
|
12
|
+
def test_initialize_time_local
|
13
|
+
tdt = TimeOrDateTime.new(Time.local(2006, 3, 24, 15, 32, 3))
|
14
14
|
assert_equal(Time.utc(2006, 3, 24, 15, 32, 3), tdt.to_time)
|
15
15
|
assert_equal('UTC', tdt.to_time.zone)
|
16
16
|
end
|
17
17
|
|
18
|
+
def test_initialize_datetime_offset
|
19
|
+
tdt = TimeOrDateTime.new(DateTime.new(2006, 3, 24, 15, 32, 3).new_offset(Rational(5, 24)))
|
20
|
+
assert_equal(DateTime.new(2006, 3, 24, 15, 32, 3), tdt.to_datetime)
|
21
|
+
assert_equal(0, tdt.to_datetime.offset)
|
22
|
+
end
|
23
|
+
|
18
24
|
def test_initialize_datetime
|
19
25
|
TimeOrDateTime.new(DateTime.new(2006, 3, 24, 15, 32, 3))
|
20
26
|
end
|
data/test/tc_timezone.rb
CHANGED
@@ -215,17 +215,22 @@ class TCTimezone < Test::Unit::TestCase
|
|
215
215
|
|
216
216
|
def test_period_for_utc
|
217
217
|
dt = DateTime.new(2005,2,18,16,24,23)
|
218
|
+
dt2 = DateTime.new(2005,2,18,16,24,23).new_offset(Rational(5,24))
|
218
219
|
t = Time.utc(2005,2,18,16,24,23)
|
219
220
|
t2 = Time.local(2005,2,18,16,24,23)
|
220
221
|
ts = t.to_i
|
221
222
|
|
222
223
|
dt_period = Timezone.get('Europe/London').period_for_utc(dt)
|
224
|
+
dt2_period = Timezone.get('Europe/London').period_for_utc(dt2)
|
223
225
|
t_period = Timezone.get('Europe/London').period_for_utc(t)
|
224
226
|
t2_period = Timezone.get('Europe/London').period_for_utc(t2)
|
225
227
|
ts_period = Timezone.get('Europe/London').period_for_utc(ts)
|
226
228
|
|
227
229
|
assert_equal(DateTime.new(2004,10,31,1,0,0), dt_period.utc_start)
|
228
|
-
assert_equal(DateTime.new(2005,3,27,1,0,0), dt_period.utc_end)
|
230
|
+
assert_equal(DateTime.new(2005,3,27,1,0,0), dt_period.utc_end)
|
231
|
+
|
232
|
+
assert_equal(DateTime.new(2004,10,31,1,0,0), dt2_period.utc_start)
|
233
|
+
assert_equal(DateTime.new(2005,3,27,1,0,0), dt2_period.utc_end)
|
229
234
|
|
230
235
|
assert_equal(DateTime.new(2004,10,31,1,0,0), t_period.utc_start)
|
231
236
|
assert_equal(DateTime.new(2005,3,27,1,0,0), t_period.utc_end)
|
@@ -239,11 +244,13 @@ class TCTimezone < Test::Unit::TestCase
|
|
239
244
|
|
240
245
|
def test_period_for_local
|
241
246
|
dt = DateTime.new(2005,2,18,16,24,23)
|
247
|
+
dt2 = DateTime.new(2005,2,18,16,24,23).new_offset(Rational(5,24))
|
242
248
|
t = Time.utc(2005,2,18,16,24,23)
|
243
249
|
t2 = Time.local(2005,2,18,16,24,23)
|
244
250
|
ts = t.to_i
|
245
251
|
|
246
252
|
dt_period = Timezone.get('Europe/London').period_for_local(dt)
|
253
|
+
dt2_period = Timezone.get('Europe/London').period_for_local(dt2)
|
247
254
|
t_period = Timezone.get('Europe/London').period_for_local(t)
|
248
255
|
t2_period = Timezone.get('Europe/London').period_for_local(t2)
|
249
256
|
ts_period = Timezone.get('Europe/London').period_for_local(ts)
|
@@ -251,6 +258,9 @@ class TCTimezone < Test::Unit::TestCase
|
|
251
258
|
assert_equal(DateTime.new(2004,10,31,1,0,0), dt_period.utc_start)
|
252
259
|
assert_equal(DateTime.new(2005,3,27,1,0,0), dt_period.utc_end)
|
253
260
|
|
261
|
+
assert_equal(DateTime.new(2004,10,31,1,0,0), dt2_period.utc_start)
|
262
|
+
assert_equal(DateTime.new(2005,3,27,1,0,0), dt2_period.utc_end)
|
263
|
+
|
254
264
|
assert_equal(DateTime.new(2004,10,31,1,0,0), t_period.utc_start)
|
255
265
|
assert_equal(DateTime.new(2005,3,27,1,0,0), t_period.utc_end)
|
256
266
|
|
@@ -358,28 +368,60 @@ class TCTimezone < Test::Unit::TestCase
|
|
358
368
|
|
359
369
|
def test_utc_to_local
|
360
370
|
dt = DateTime.new(2005,2,18,16,24,23)
|
371
|
+
dt2 = DateTime.new(2005,2,18,16,24,23).new_offset(Rational(5,24))
|
361
372
|
t = Time.utc(2005,2,18,16,24,23)
|
362
373
|
t2 = Time.local(2005,2,18,16,24,23)
|
363
374
|
ts = t.to_i
|
364
375
|
|
365
376
|
assert_equal(dt, Timezone.get('Europe/London').utc_to_local(dt))
|
377
|
+
assert_equal(dt2, Timezone.get('Europe/London').utc_to_local(dt2))
|
366
378
|
assert_equal(t, Timezone.get('Europe/London').utc_to_local(t))
|
367
379
|
assert_equal(t, Timezone.get('Europe/London').utc_to_local(t2))
|
368
380
|
assert_equal(ts, Timezone.get('Europe/London').utc_to_local(ts))
|
369
|
-
end
|
381
|
+
end
|
382
|
+
|
383
|
+
def test_utc_to_local_offset
|
384
|
+
dt = DateTime.new(2005,2,18,16,24,23)
|
385
|
+
dt2 = DateTime.new(2005,2,18,16,24,23).new_offset(Rational(5,24))
|
386
|
+
t = Time.utc(2005,2,18,16,24,23)
|
387
|
+
t2 = Time.local(2005,2,18,16,24,23)
|
388
|
+
|
389
|
+
assert_equal(0, Timezone.get('Europe/London').utc_to_local(dt).offset)
|
390
|
+
assert_equal(0, Timezone.get('Europe/London').utc_to_local(dt2).offset)
|
391
|
+
assert_equal(0, Timezone.get('Europe/London').utc_to_local(t).utc_offset)
|
392
|
+
assert_equal('UTC', Timezone.get('Europe/London').utc_to_local(t).zone)
|
393
|
+
assert_equal(0, Timezone.get('Europe/London').utc_to_local(t2).utc_offset)
|
394
|
+
assert_equal('UTC', Timezone.get('Europe/London').utc_to_local(t2).zone)
|
395
|
+
end
|
370
396
|
|
371
397
|
def test_local_to_utc
|
372
398
|
dt = DateTime.new(2005,2,18,16,24,23)
|
399
|
+
dt2 = DateTime.new(2005,2,18,16,24,23)
|
373
400
|
t = Time.utc(2005,2,18,16,24,23)
|
374
401
|
t2 = Time.local(2005,2,18,16,24,23)
|
375
402
|
ts = t.to_i
|
376
403
|
|
377
|
-
assert_equal(dt, Timezone.get('Europe/London').local_to_utc(dt))
|
404
|
+
assert_equal(dt, Timezone.get('Europe/London').local_to_utc(dt))
|
405
|
+
assert_equal(dt2, Timezone.get('Europe/London').local_to_utc(dt2))
|
378
406
|
assert_equal(t, Timezone.get('Europe/London').local_to_utc(t))
|
379
407
|
assert_equal(t, Timezone.get('Europe/London').local_to_utc(t2))
|
380
408
|
assert_equal(ts, Timezone.get('Europe/London').local_to_utc(ts))
|
381
409
|
end
|
382
410
|
|
411
|
+
def test_local_to_utc_offset
|
412
|
+
dt = DateTime.new(2005,2,18,16,24,23)
|
413
|
+
dt2 = DateTime.new(2005,2,18,16,24,23).new_offset(Rational(5,24))
|
414
|
+
t = Time.utc(2005,2,18,16,24,23)
|
415
|
+
t2 = Time.local(2005,2,18,16,24,23)
|
416
|
+
|
417
|
+
assert_equal(0, Timezone.get('Europe/London').local_to_utc(dt).offset)
|
418
|
+
assert_equal(0, Timezone.get('Europe/London').local_to_utc(dt2).offset)
|
419
|
+
assert_equal(0, Timezone.get('Europe/London').local_to_utc(t).utc_offset)
|
420
|
+
assert_equal('UTC', Timezone.get('Europe/London').local_to_utc(t).zone)
|
421
|
+
assert_equal(0, Timezone.get('Europe/London').local_to_utc(t2).utc_offset)
|
422
|
+
assert_equal('UTC', Timezone.get('Europe/London').local_to_utc(t2).zone)
|
423
|
+
end
|
424
|
+
|
383
425
|
def test_local_to_utc_invalid
|
384
426
|
assert_raise(PeriodNotFound) {
|
385
427
|
Timezone.get('America/New_York').local_to_utc(DateTime.new(2004,4,4,2,30,0))
|
data/test/tc_timezone_period.rb
CHANGED
@@ -12,7 +12,8 @@ class TCTimezonePeriod < Test::Unit::TestCase
|
|
12
12
|
assert_equal(DateTime.new(2005,1,2,0,0,0), p.utc_end)
|
13
13
|
assert_equal(-7200, p.utc_offset)
|
14
14
|
assert_equal(3600, p.std_offset)
|
15
|
-
assert_equal(:TEST, p.zone_identifier)
|
15
|
+
assert_equal(:TEST, p.zone_identifier)
|
16
|
+
assert_equal(:TEST, p.abbreviation)
|
16
17
|
assert_equal(DateTime.new(2004,12,31,23,0,0), p.local_start)
|
17
18
|
assert_equal(DateTime.new(2005,1,1,23,0,0), p.local_end)
|
18
19
|
end
|
@@ -24,7 +25,8 @@ class TCTimezonePeriod < Test::Unit::TestCase
|
|
24
25
|
assert_equal(DateTime.new(2005,1,2,0,0,0), p.utc_end)
|
25
26
|
assert_equal(-7200, p.utc_offset)
|
26
27
|
assert_equal(3600, p.std_offset)
|
27
|
-
assert_equal(:TEST, p.zone_identifier)
|
28
|
+
assert_equal(:TEST, p.zone_identifier)
|
29
|
+
assert_equal(:TEST, p.abbreviation)
|
28
30
|
assert_equal(DateTime.new(2004,12,31,23,0,0), p.local_start)
|
29
31
|
assert_equal(DateTime.new(2005,1,1,23,0,0), p.local_end)
|
30
32
|
end
|
@@ -36,7 +38,8 @@ class TCTimezonePeriod < Test::Unit::TestCase
|
|
36
38
|
assert_equal(DateTime.new(2005,1,2,0,0,0), p.utc_end)
|
37
39
|
assert_equal(-7200, p.utc_offset)
|
38
40
|
assert_equal(3600, p.std_offset)
|
39
|
-
assert_equal(:TEST, p.zone_identifier)
|
41
|
+
assert_equal(:TEST, p.zone_identifier)
|
42
|
+
assert_equal(:TEST, p.abbreviation)
|
40
43
|
assert_equal(DateTime.new(2004,12,31,23,0,0), p.local_start)
|
41
44
|
assert_equal(DateTime.new(2005,1,1,23,0,0), p.local_end)
|
42
45
|
end
|
@@ -49,6 +52,7 @@ class TCTimezonePeriod < Test::Unit::TestCase
|
|
49
52
|
assert_equal(-7200, p.utc_offset)
|
50
53
|
assert_equal(3600, p.std_offset)
|
51
54
|
assert_equal(:TEST, p.zone_identifier)
|
55
|
+
assert_equal(:TEST, p.abbreviation)
|
52
56
|
assert_nil(p.local_start)
|
53
57
|
assert_nil(p.local_end)
|
54
58
|
end
|