|
4 | 4 |
|
5 | 5 | # DST in 2010 is March 14th at 2am
|
6 | 6 | it 'crosses a daylight savings time boundary with a recurrence rule in local time, by utc conversion' do
|
7 |
| - start_date = Time.local(2010, 3, 13, 5, 0, 0) |
8 |
| - schedule = IceCube::Schedule.new(start_date) |
| 7 | + start_time = Time.local(2010, 3, 13, 5, 0, 0) |
| 8 | + schedule = IceCube::Schedule.new(start_time) |
9 | 9 | schedule.add_recurrence_rule IceCube::Rule.daily.count(20)
|
10 | 10 | dates = schedule.first(20)
|
11 | 11 | dates.size.should == 20
|
|
18 | 18 |
|
19 | 19 | # DST in 2010 is November 7th at 2am
|
20 | 20 | it 'crosses a daylight savings time boundary (in the other direction) with a recurrence rule in local time, by utc conversion' do
|
21 |
| - start_date = Time.local(2010, 11, 6, 5, 0, 0) |
22 |
| - schedule = IceCube::Schedule.new(start_date) |
| 21 | + start_time = Time.local(2010, 11, 6, 5, 0, 0) |
| 22 | + schedule = IceCube::Schedule.new(start_time) |
23 | 23 | schedule.add_recurrence_rule IceCube::Rule.daily.count(20)
|
24 | 24 | dates = schedule.first(20)
|
25 | 25 | dates.size.should == 20
|
|
31 | 31 | end
|
32 | 32 |
|
33 | 33 | it 'cross a daylight savings time boundary with a recurrence rule in local time' do
|
34 |
| - start_date = Time.local(2010, 3, 14, 5, 0, 0) |
35 |
| - schedule = IceCube::Schedule.new(start_date) |
| 34 | + start_time = Time.local(2010, 3, 14, 5, 0, 0) |
| 35 | + schedule = IceCube::Schedule.new(start_time) |
36 | 36 | schedule.add_recurrence_rule IceCube::Rule.daily
|
37 | 37 | # each occurrence MUST occur at 5pm, then we win
|
38 |
| - dates = schedule.occurrences(start_date + 20 * IceCube::ONE_DAY) |
39 |
| - last = start_date |
| 38 | + dates = schedule.occurrences(start_time + 20 * IceCube::ONE_DAY) |
| 39 | + last = start_time |
40 | 40 | dates.each do |date|
|
41 | 41 | date.hour.should == 5
|
42 | 42 | last = date
|
43 | 43 | end
|
44 | 44 | end
|
45 | 45 |
|
46 | 46 | it 'every two hours over a daylight savings time boundary, checking interval' do
|
47 |
| - start_date = Time.local(2010, 11, 6, 5, 0, 0) |
48 |
| - schedule = IceCube::Schedule.new(start_date) |
| 47 | + start_time = Time.local(2010, 11, 6, 5, 0, 0) |
| 48 | + schedule = IceCube::Schedule.new(start_time) |
49 | 49 | schedule.add_recurrence_rule IceCube::Rule.hourly(2)
|
50 | 50 | dates = schedule.first(100)
|
51 | 51 | #check assumption
|
52 | 52 | distance_in_hours = 0
|
53 | 53 | dates.each do |d|
|
54 |
| - d.should == start_date + IceCube::ONE_HOUR * distance_in_hours |
| 54 | + d.should == start_time + IceCube::ONE_HOUR * distance_in_hours |
55 | 55 | distance_in_hours += 2
|
56 | 56 | end
|
57 | 57 | end
|
58 | 58 |
|
59 | 59 | it 'every 30 minutes over a daylight savings time boundary, checking interval' do
|
60 |
| - start_date = Time.local(2010, 11, 6, 23, 0, 0) |
61 |
| - schedule = IceCube::Schedule.new(start_date) |
| 60 | + start_time = Time.local(2010, 11, 6, 23, 0, 0) |
| 61 | + schedule = IceCube::Schedule.new(start_time) |
62 | 62 | schedule.add_recurrence_rule IceCube::Rule.minutely(30)
|
63 | 63 | dates = schedule.first(100)
|
64 | 64 | #check assumption
|
65 | 65 | distance_in_minutes = 0
|
66 | 66 | dates.each do |d|
|
67 |
| - d.should == start_date + IceCube::ONE_MINUTE * distance_in_minutes |
| 67 | + d.should == start_time + IceCube::ONE_MINUTE * distance_in_minutes |
68 | 68 | distance_in_minutes += 30
|
69 | 69 | end
|
70 | 70 | end
|
71 | 71 |
|
72 | 72 | it 'every 120 seconds over a daylight savings time boundary, checking interval' do
|
73 |
| - start_date = Time.local(2010, 11, 6, 23, 50, 0) |
74 |
| - schedule = IceCube::Schedule.new(start_date) |
| 73 | + start_time = Time.local(2010, 11, 6, 23, 50, 0) |
| 74 | + schedule = IceCube::Schedule.new(start_time) |
75 | 75 | schedule.add_recurrence_rule IceCube::Rule.secondly(120)
|
76 | 76 | dates = schedule.first(10)
|
77 | 77 | #check assumption
|
78 | 78 | distance_in_seconds = 0
|
79 | 79 | dates.each do |d|
|
80 |
| - d.should == start_date + distance_in_seconds |
| 80 | + d.should == start_time + distance_in_seconds |
81 | 81 | distance_in_seconds += 120
|
82 | 82 | end
|
83 | 83 | end
|
84 | 84 |
|
85 | 85 | it 'every other day over a daylight savings time boundary, checking hour/min/sec' do
|
86 |
| - start_date = Time.local(2010, 11, 6, 20, 0, 0) |
87 |
| - schedule = IceCube::Schedule.new(start_date) |
| 86 | + start_time = Time.local(2010, 11, 6, 20, 0, 0) |
| 87 | + schedule = IceCube::Schedule.new(start_time) |
88 | 88 | schedule.add_recurrence_rule IceCube::Rule.daily(2)
|
89 | 89 | dates = schedule.first(10)
|
90 | 90 | #check assumption
|
91 | 91 | dates.each do |d|
|
92 |
| - d.hour.should == start_date.hour |
93 |
| - d.min.should == start_date.min |
94 |
| - d.sec.should == start_date.sec |
| 92 | + d.hour.should == start_time.hour |
| 93 | + d.min.should == start_time.min |
| 94 | + d.sec.should == start_time.sec |
95 | 95 | end
|
96 | 96 | end
|
97 | 97 |
|
98 | 98 | it 'every other month over a daylight savings time boundary, checking day/hour/min/sec' do
|
99 |
| - start_date = Time.local(2010, 11, 6, 20, 0, 0) |
100 |
| - schedule = IceCube::Schedule.new(start_date) |
| 99 | + start_time = Time.local(2010, 11, 6, 20, 0, 0) |
| 100 | + schedule = IceCube::Schedule.new(start_time) |
101 | 101 | schedule.add_recurrence_rule IceCube::Rule.monthly(2)
|
102 | 102 | dates = schedule.first(10)
|
103 | 103 | #check assumption
|
104 | 104 | dates.each do |d|
|
105 |
| - d.day.should == start_date.day |
106 |
| - d.hour.should == start_date.hour |
107 |
| - d.min.should == start_date.min |
108 |
| - d.sec.should == start_date.sec |
| 105 | + d.day.should == start_time.day |
| 106 | + d.hour.should == start_time.hour |
| 107 | + d.min.should == start_time.min |
| 108 | + d.sec.should == start_time.sec |
109 | 109 | end
|
110 | 110 | end
|
111 | 111 |
|
112 | 112 | it 'every other year over a daylight savings time boundary, checking day/hour/min/sec' do
|
113 |
| - start_date = Time.local(2010, 11, 6, 20, 0, 0) |
114 |
| - schedule = IceCube::Schedule.new(start_date) |
| 113 | + start_time = Time.local(2010, 11, 6, 20, 0, 0) |
| 114 | + schedule = IceCube::Schedule.new(start_time) |
115 | 115 | schedule.add_recurrence_rule IceCube::Rule.yearly(2)
|
116 | 116 | dates = schedule.first(10)
|
117 | 117 | #check assumption
|
118 | 118 | dates.each do |d|
|
119 |
| - d.month.should == start_date.month |
120 |
| - d.day.should == start_date.day |
121 |
| - d.hour.should == start_date.hour |
122 |
| - d.min.should == start_date.min |
123 |
| - d.sec.should == start_date.sec |
| 119 | + d.month.should == start_time.month |
| 120 | + d.day.should == start_time.day |
| 121 | + d.hour.should == start_time.hour |
| 122 | + d.min.should == start_time.min |
| 123 | + d.sec.should == start_time.sec |
124 | 124 | end
|
125 | 125 | end
|
126 | 126 |
|
127 | 127 | it 'LOCAL - has an until date on a rule that is over a DST from the start date' do
|
128 |
| - start_date = Time.local(2010, 3, 13, 5, 0, 0) |
| 128 | + start_time = Time.local(2010, 3, 13, 5, 0, 0) |
129 | 129 | end_date = Time.local(2010, 3, 15, 5, 0, 0)
|
130 |
| - schedule = IceCube::Schedule.new(start_date) |
| 130 | + schedule = IceCube::Schedule.new(start_time) |
131 | 131 | schedule.add_recurrence_rule IceCube::Rule.daily.until(end_date)
|
132 | 132 | #make sure we end on the proper time
|
133 | 133 | schedule.all_occurrences.last.should == end_date
|
134 | 134 | end
|
135 | 135 |
|
136 | 136 | it 'UTC - has an until date on a rule that is over a DST from the start date' do
|
137 |
| - start_date = Time.utc(2010, 3, 13, 5, 0, 0) |
| 137 | + start_time = Time.utc(2010, 3, 13, 5, 0, 0) |
138 | 138 | end_date = Time.utc(2010, 3, 15, 5, 0, 0)
|
139 |
| - schedule = IceCube::Schedule.new(start_date) |
| 139 | + schedule = IceCube::Schedule.new(start_time) |
140 | 140 | schedule.add_recurrence_rule IceCube::Rule.daily.until(end_date)
|
141 | 141 | #make sure we end on the proper time
|
142 | 142 | schedule.all_occurrences.last.should == end_date
|
143 | 143 | end
|
144 | 144 |
|
145 | 145 | it 'LOCAL - has an until date on a rule that is over a DST from the start date (other direction)' do
|
146 |
| - start_date = Time.local(2010, 11, 5, 5, 0, 0) |
| 146 | + start_time = Time.local(2010, 11, 5, 5, 0, 0) |
147 | 147 | end_date = Time.local(2010, 11, 10, 5, 0, 0)
|
148 |
| - schedule = IceCube::Schedule.new(start_date) |
| 148 | + schedule = IceCube::Schedule.new(start_time) |
149 | 149 | schedule.add_recurrence_rule IceCube::Rule.daily.until(end_date)
|
150 | 150 | #make sure we end on the proper time
|
151 | 151 | schedule.all_occurrences.last.should == end_date
|
152 | 152 | end
|
153 | 153 |
|
154 | 154 | it 'UTC - has an until date on a rule that is over a DST from the start date (other direction)' do
|
155 |
| - start_date = Time.utc(2010, 11, 5, 5, 0, 0) |
| 155 | + start_time = Time.utc(2010, 11, 5, 5, 0, 0) |
156 | 156 | end_date = Time.utc(2010, 11, 10, 5, 0, 0)
|
157 |
| - schedule = IceCube::Schedule.new(start_date) |
| 157 | + schedule = IceCube::Schedule.new(start_time) |
158 | 158 | schedule.add_recurrence_rule IceCube::Rule.daily.until(end_date)
|
159 | 159 | #make sure we end on the proper time
|
160 | 160 | schedule.all_occurrences.last.should == end_date
|
161 | 161 | end
|
162 | 162 |
|
163 | 163 | it 'LOCAL - has an end date on a rule that is over a DST from the start date' do
|
164 |
| - start_date = Time.local(2010, 3, 13, 5, 0, 0) |
| 164 | + start_time = Time.local(2010, 3, 13, 5, 0, 0) |
165 | 165 | end_date = Time.local(2010, 3, 15, 5, 0, 0)
|
166 |
| - schedule = IceCube::Schedule.new(start_date) |
| 166 | + schedule = IceCube::Schedule.new(start_time) |
167 | 167 | schedule.add_recurrence_rule IceCube::Rule.daily
|
168 | 168 | #make sure we end on the proper time
|
169 | 169 | schedule.occurrences(end_date).last.should == end_date
|
170 | 170 | end
|
171 | 171 |
|
172 | 172 | it 'UTC - has an end date on a rule that is over a DST from the start date' do
|
173 |
| - start_date = Time.utc(2010, 3, 13, 5, 0, 0) |
| 173 | + start_time = Time.utc(2010, 3, 13, 5, 0, 0) |
174 | 174 | end_date = Time.utc(2010, 3, 15, 5, 0, 0)
|
175 |
| - schedule = IceCube::Schedule.new(start_date) |
| 175 | + schedule = IceCube::Schedule.new(start_time) |
176 | 176 | schedule.add_recurrence_rule IceCube::Rule.daily
|
177 | 177 | #make sure we end on the proper time
|
178 | 178 | schedule.occurrences(end_date).last.should == end_date
|
179 | 179 | end
|
180 | 180 |
|
181 | 181 | it 'LOCAL - has an end date on a rule that is over a DST from the start date (other direction)' do
|
182 |
| - start_date = Time.local(2010, 11, 5, 5, 0, 0) |
| 182 | + start_time = Time.local(2010, 11, 5, 5, 0, 0) |
183 | 183 | end_date = Time.local(2010, 11, 10, 5, 0, 0)
|
184 |
| - schedule = IceCube::Schedule.new(start_date) |
| 184 | + schedule = IceCube::Schedule.new(start_time) |
185 | 185 | schedule.add_recurrence_rule IceCube::Rule.daily
|
186 | 186 | #make sure we end on the proper time
|
187 | 187 | schedule.occurrences(end_date).last.should == end_date
|
188 | 188 | end
|
189 | 189 |
|
190 | 190 | it 'UTC - has an end date on a rule that is over a DST from the start date (other direction)' do
|
191 |
| - start_date = Time.utc(2010, 11, 5, 5, 0, 0) |
| 191 | + start_time = Time.utc(2010, 11, 5, 5, 0, 0) |
192 | 192 | end_date = Time.utc(2010, 11, 10, 5, 0, 0)
|
193 |
| - schedule = IceCube::Schedule.new(start_date) |
| 193 | + schedule = IceCube::Schedule.new(start_time) |
194 | 194 | schedule.add_recurrence_rule IceCube::Rule.daily
|
195 | 195 | #make sure we end on the proper time
|
196 | 196 | schedule.occurrences(end_date).last.should == end_date
|
197 | 197 | end
|
198 | 198 |
|
199 | 199 | it 'local - should make dates on interval over dst - github issue 4' do
|
200 |
| - start_date = Time.local(2010, 3, 12, 19, 0, 0) |
201 |
| - schedule = IceCube::Schedule.new(start_date) |
| 200 | + start_time = Time.local(2010, 3, 12, 19, 0, 0) |
| 201 | + schedule = IceCube::Schedule.new(start_time) |
202 | 202 | schedule.add_recurrence_rule IceCube::Rule.daily(3)
|
203 | 203 | schedule.first(3).should == [Time.local(2010, 3, 12, 19, 0, 0), Time.local(2010, 3, 15, 19, 0, 0), Time.local(2010, 3, 18, 19, 0, 0)]
|
204 | 204 | end
|
205 | 205 |
|
206 | 206 | it 'local - should make dates on monthly interval over dst - github issue 4' do
|
207 |
| - start_date = Time.local(2010, 3, 12, 19, 0, 0) |
208 |
| - schedule = IceCube::Schedule.new(start_date) |
| 207 | + start_time = Time.local(2010, 3, 12, 19, 0, 0) |
| 208 | + schedule = IceCube::Schedule.new(start_time) |
209 | 209 | schedule.add_recurrence_rule IceCube::Rule.monthly(2)
|
210 | 210 | schedule.first(6).should == [Time.local(2010, 3, 12, 19, 0, 0), Time.local(2010, 5, 12, 19, 0, 0), Time.local(2010, 7, 12, 19, 0, 0),
|
211 | 211 | Time.local(2010, 9, 12, 19, 0, 0), Time.local(2010, 11, 12, 19, 0, 0), Time.local(2011, 1, 12, 19, 0, 0)]
|
212 | 212 | end
|
213 | 213 |
|
214 | 214 | it 'local - should make dates on monthly interval over dst - github issue 4' do
|
215 |
| - start_date = Time.local(2010, 3, 12, 19, 0, 0) |
216 |
| - schedule = IceCube::Schedule.new(start_date) |
| 215 | + start_time = Time.local(2010, 3, 12, 19, 0, 0) |
| 216 | + schedule = IceCube::Schedule.new(start_time) |
217 | 217 | schedule.add_recurrence_rule IceCube::Rule.monthly
|
218 | 218 | schedule.first(10).should == [Time.local(2010, 3, 12, 19, 0, 0), Time.local(2010, 4, 12, 19, 0, 0), Time.local(2010, 5, 12, 19, 0, 0),
|
219 | 219 | Time.local(2010, 6, 12, 19, 0, 0), Time.local(2010, 7, 12, 19, 0, 0), Time.local(2010, 8, 12, 19, 0, 0),
|
|
222 | 222 | end
|
223 | 223 |
|
224 | 224 | it 'local - should make dates on yearly interval over dst - github issue 4' do
|
225 |
| - start_date = Time.local(2010, 3, 12, 19, 0, 0) |
226 |
| - schedule = IceCube::Schedule.new(start_date) |
| 225 | + start_time = Time.local(2010, 3, 12, 19, 0, 0) |
| 226 | + schedule = IceCube::Schedule.new(start_time) |
227 | 227 | schedule.add_recurrence_rule IceCube::Rule.yearly(2)
|
228 | 228 | schedule.first(3).should == [Time.local(2010, 3, 12, 19, 0, 0), Time.local(2012, 3, 12, 19, 0, 0), Time.local(2014, 3, 12, 19, 0, 0)]
|
229 | 229 | end
|
230 | 230 |
|
231 | 231 | it "local - should make dates on monthly (day of week) inverval over dst - github issue 5" do
|
232 |
| - start_date = Time.local(2010, 3, 7, 12, 0, 0) |
233 |
| - schedule = IceCube::Schedule.new(start_date) |
| 232 | + start_time = Time.local(2010, 3, 7, 12, 0, 0) |
| 233 | + schedule = IceCube::Schedule.new(start_time) |
234 | 234 | schedule.add_recurrence_rule IceCube::Rule.monthly.day_of_week(:sunday => [1])
|
235 | 235 | schedule.first(3).should == [Time.local(2010, 3, 7, 12, 0, 0), Time.local(2010, 4, 4, 12, 0, 0), Time.local(2010, 5, 2, 12, 0, 0)]
|
236 | 236 | end
|
237 | 237 |
|
238 | 238 | it "local - should make dates on monthly (day of month) inverval over dst - github issue 5" do
|
239 |
| - start_date = Time.local(2010, 3, 1, 12, 0, 0) |
240 |
| - schedule = IceCube::Schedule.new(start_date) |
| 239 | + start_time = Time.local(2010, 3, 1, 12, 0, 0) |
| 240 | + schedule = IceCube::Schedule.new(start_time) |
241 | 241 | schedule.add_recurrence_rule IceCube::Rule.monthly.day_of_month(1)
|
242 | 242 | schedule.first(3).should == [Time.local(2010, 3, 1, 12, 0, 0), Time.local(2010, 4, 1, 12, 0, 0), Time.local(2010, 5, 1, 12, 0, 0)]
|
243 | 243 | end
|
244 | 244 |
|
245 | 245 | it "local - should make dates on weekly (day) inverval over dst - github issue 5" do
|
246 |
| - start_date = Time.local(2010, 3, 7, 12, 0, 0) |
247 |
| - schedule = IceCube::Schedule.new(start_date) |
| 246 | + start_time = Time.local(2010, 3, 7, 12, 0, 0) |
| 247 | + schedule = IceCube::Schedule.new(start_time) |
248 | 248 | schedule.add_recurrence_rule IceCube::Rule.weekly.day(:sunday)
|
249 | 249 | schedule.first(3).should == [Time.local(2010, 3, 7, 12, 0, 0), Time.local(2010, 3, 14, 12, 0, 0), Time.local(2010, 3, 21, 12, 0, 0)]
|
250 | 250 | end
|
251 | 251 |
|
252 | 252 | it "local - should make dates on monthly (day of year) inverval over dst - github issue 5" do
|
253 |
| - start_date = Time.local(2010, 3, 7, 12, 0, 0) |
254 |
| - schedule = IceCube::Schedule.new(start_date) |
| 253 | + start_time = Time.local(2010, 3, 7, 12, 0, 0) |
| 254 | + schedule = IceCube::Schedule.new(start_time) |
255 | 255 | schedule.add_recurrence_rule IceCube::Rule.monthly.day_of_year(1)
|
256 | 256 | schedule.first(3).should == [Time.local(2011, 1, 1, 12, 0, 0), Time.local(2012, 1, 1, 12, 0, 0), Time.local(2013, 1, 1, 12, 0, 0)]
|
257 | 257 | end
|
258 | 258 |
|
259 | 259 | it "local - should make dates on monthly (month_of_year) inverval over dst - github issue 5" do
|
260 |
| - start_date = Time.local(2010, 3, 7, 12, 0, 0) |
261 |
| - schedule = IceCube::Schedule.new(start_date) |
| 260 | + start_time = Time.local(2010, 3, 7, 12, 0, 0) |
| 261 | + schedule = IceCube::Schedule.new(start_time) |
262 | 262 | schedule.add_recurrence_rule IceCube::Rule.yearly.month_of_year(:april).day_of_month(10)
|
263 | 263 | schedule.first(3).should == [Time.local(2010, 4, 10, 12, 0, 0), Time.local(2011, 4, 10, 12, 0, 0), Time.local(2012, 4, 10, 12, 0, 0)]
|
264 | 264 | end
|
|
0 commit comments