Hokkaido 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Gemfile +2 -0
- data/Gemfile.lock +2 -2
- data/ansiterm-color/.gitignore +3 -0
- data/ansiterm-color/CHANGES +28 -0
- data/ansiterm-color/COPYING +340 -0
- data/ansiterm-color/README +137 -0
- data/ansiterm-color/Rakefile +88 -0
- data/ansiterm-color/VERSION +1 -0
- data/ansiterm-color/bin/cdiff +19 -0
- data/ansiterm-color/bin/decolor +12 -0
- data/ansiterm-color/doc-main.txt +119 -0
- data/ansiterm-color/examples/example.rb +90 -0
- data/ansiterm-color/install.rb +15 -0
- data/ansiterm-color/lib/term/ansicolor/.keep +0 -0
- data/ansiterm-color/lib/term/ansicolor/version.rb +10 -0
- data/ansiterm-color/lib/term/ansicolor.rb +102 -0
- data/ansiterm-color/make_doc.rb +4 -0
- data/ansiterm-color/tests/ansicolor_test.rb +66 -0
- data/chronic/.gitignore +6 -0
- data/chronic/HISTORY.md +205 -0
- data/chronic/LICENSE +21 -0
- data/chronic/README.md +181 -0
- data/chronic/Rakefile +46 -0
- data/chronic/chronic.gemspec +20 -0
- data/chronic/lib/chronic/grabber.rb +33 -0
- data/chronic/lib/chronic/handler.rb +88 -0
- data/chronic/lib/chronic/handlers.rb +572 -0
- data/chronic/lib/chronic/mini_date.rb +38 -0
- data/chronic/lib/chronic/numerizer.rb +121 -0
- data/chronic/lib/chronic/ordinal.rb +47 -0
- data/chronic/lib/chronic/pointer.rb +32 -0
- data/chronic/lib/chronic/repeater.rb +145 -0
- data/chronic/lib/chronic/repeaters/repeater_day.rb +53 -0
- data/chronic/lib/chronic/repeaters/repeater_day_name.rb +52 -0
- data/chronic/lib/chronic/repeaters/repeater_day_portion.rb +108 -0
- data/chronic/lib/chronic/repeaters/repeater_fortnight.rb +71 -0
- data/chronic/lib/chronic/repeaters/repeater_hour.rb +58 -0
- data/chronic/lib/chronic/repeaters/repeater_minute.rb +58 -0
- data/chronic/lib/chronic/repeaters/repeater_month.rb +79 -0
- data/chronic/lib/chronic/repeaters/repeater_month_name.rb +94 -0
- data/chronic/lib/chronic/repeaters/repeater_season.rb +109 -0
- data/chronic/lib/chronic/repeaters/repeater_season_name.rb +43 -0
- data/chronic/lib/chronic/repeaters/repeater_second.rb +42 -0
- data/chronic/lib/chronic/repeaters/repeater_time.rb +128 -0
- data/chronic/lib/chronic/repeaters/repeater_week.rb +74 -0
- data/chronic/lib/chronic/repeaters/repeater_weekday.rb +85 -0
- data/chronic/lib/chronic/repeaters/repeater_weekend.rb +66 -0
- data/chronic/lib/chronic/repeaters/repeater_year.rb +77 -0
- data/chronic/lib/chronic/scalar.rb +116 -0
- data/chronic/lib/chronic/season.rb +26 -0
- data/chronic/lib/chronic/separator.rb +94 -0
- data/chronic/lib/chronic/span.rb +31 -0
- data/chronic/lib/chronic/tag.rb +36 -0
- data/chronic/lib/chronic/time_zone.rb +32 -0
- data/chronic/lib/chronic/token.rb +47 -0
- data/chronic/lib/chronic.rb +442 -0
- data/chronic/test/helper.rb +12 -0
- data/chronic/test/test_chronic.rb +150 -0
- data/chronic/test/test_daylight_savings.rb +118 -0
- data/chronic/test/test_handler.rb +104 -0
- data/chronic/test/test_mini_date.rb +32 -0
- data/chronic/test/test_numerizer.rb +72 -0
- data/chronic/test/test_parsing.rb +1061 -0
- data/chronic/test/test_repeater_day_name.rb +51 -0
- data/chronic/test/test_repeater_day_portion.rb +254 -0
- data/chronic/test/test_repeater_fortnight.rb +62 -0
- data/chronic/test/test_repeater_hour.rb +68 -0
- data/chronic/test/test_repeater_minute.rb +34 -0
- data/chronic/test/test_repeater_month.rb +50 -0
- data/chronic/test/test_repeater_month_name.rb +56 -0
- data/chronic/test/test_repeater_season.rb +40 -0
- data/chronic/test/test_repeater_time.rb +70 -0
- data/chronic/test/test_repeater_week.rb +62 -0
- data/chronic/test/test_repeater_weekday.rb +55 -0
- data/chronic/test/test_repeater_weekend.rb +74 -0
- data/chronic/test/test_repeater_year.rb +69 -0
- data/chronic/test/test_span.rb +23 -0
- data/chronic/test/test_token.rb +25 -0
- data/lib/Hokkaido/version.rb +1 -1
- data/lib/Hokkaido.rb +13 -9
- data/lib/gem_modifier.rb +23 -3
- data/lib/term/ansicolor.rb +4 -1
- data/spec/Hokkaido/port_spec.rb +15 -7
- metadata +78 -2
@@ -0,0 +1,51 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
class TestRepeaterDayName < TestCase
|
4
|
+
|
5
|
+
def setup
|
6
|
+
@now = Time.local(2006, 8, 16, 14, 0, 0, 0)
|
7
|
+
end
|
8
|
+
|
9
|
+
def test_match
|
10
|
+
token = Chronic::Token.new('saturday')
|
11
|
+
repeater = Chronic::Repeater.scan_for_day_names(token)
|
12
|
+
assert_equal Chronic::RepeaterDayName, repeater.class
|
13
|
+
assert_equal :saturday, repeater.type
|
14
|
+
|
15
|
+
token = Chronic::Token.new('sunday')
|
16
|
+
repeater = Chronic::Repeater.scan_for_day_names(token)
|
17
|
+
assert_equal Chronic::RepeaterDayName, repeater.class
|
18
|
+
assert_equal :sunday, repeater.type
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_next_future
|
22
|
+
mondays = Chronic::RepeaterDayName.new(:monday)
|
23
|
+
mondays.start = @now
|
24
|
+
|
25
|
+
span = mondays.next(:future)
|
26
|
+
|
27
|
+
assert_equal Time.local(2006, 8, 21), span.begin
|
28
|
+
assert_equal Time.local(2006, 8, 22), span.end
|
29
|
+
|
30
|
+
span = mondays.next(:future)
|
31
|
+
|
32
|
+
assert_equal Time.local(2006, 8, 28), span.begin
|
33
|
+
assert_equal Time.local(2006, 8, 29), span.end
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_next_past
|
37
|
+
mondays = Chronic::RepeaterDayName.new(:monday)
|
38
|
+
mondays.start = @now
|
39
|
+
|
40
|
+
span = mondays.next(:past)
|
41
|
+
|
42
|
+
assert_equal Time.local(2006, 8, 14), span.begin
|
43
|
+
assert_equal Time.local(2006, 8, 15), span.end
|
44
|
+
|
45
|
+
span = mondays.next(:past)
|
46
|
+
|
47
|
+
assert_equal Time.local(2006, 8, 7), span.begin
|
48
|
+
assert_equal Time.local(2006, 8, 8), span.end
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
@@ -0,0 +1,254 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
class TestRepeaterDayPortion < TestCase
|
4
|
+
|
5
|
+
def setup
|
6
|
+
@now = Time.local(2006, 8, 16, 14, 0, 0, 0)
|
7
|
+
end
|
8
|
+
|
9
|
+
def test_am_future
|
10
|
+
day_portion = Chronic::RepeaterDayPortion.new(:am)
|
11
|
+
day_portion.start = @now
|
12
|
+
|
13
|
+
next_time = day_portion.next(:future)
|
14
|
+
assert_equal Time.local(2006, 8, 17, 00), next_time.begin
|
15
|
+
assert_equal Time.local(2006, 8, 17, 11, 59, 59), next_time.end
|
16
|
+
|
17
|
+
next_next_time = day_portion.next(:future)
|
18
|
+
assert_equal Time.local(2006, 8, 18, 00), next_next_time.begin
|
19
|
+
assert_equal Time.local(2006, 8, 18, 11, 59, 59), next_next_time.end
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_am_past
|
23
|
+
day_portion = Chronic::RepeaterDayPortion.new(:am)
|
24
|
+
day_portion.start = @now
|
25
|
+
|
26
|
+
next_time = day_portion.next(:past)
|
27
|
+
assert_equal Time.local(2006, 8, 16, 00), next_time.begin
|
28
|
+
assert_equal Time.local(2006, 8, 16, 11, 59, 59), next_time.end
|
29
|
+
|
30
|
+
next_next_time = day_portion.next(:past)
|
31
|
+
assert_equal Time.local(2006, 8, 15, 00), next_next_time.begin
|
32
|
+
assert_equal Time.local(2006, 8, 15, 11, 59, 59), next_next_time.end
|
33
|
+
end
|
34
|
+
|
35
|
+
def test_am_future_with_daylight_savings_time_boundary
|
36
|
+
@now = Time.local(2012,11,3,0,0,0)
|
37
|
+
day_portion = Chronic::RepeaterDayPortion.new(:am)
|
38
|
+
day_portion.start = @now
|
39
|
+
|
40
|
+
next_time = day_portion.next(:future)
|
41
|
+
assert_equal Time.local(2012, 11, 4, 00), next_time.begin
|
42
|
+
assert_equal Time.local(2012, 11, 4, 11, 59, 59), next_time.end
|
43
|
+
|
44
|
+
next_next_time = day_portion.next(:future)
|
45
|
+
|
46
|
+
assert_equal Time.local(2012, 11, 5, 00), next_next_time.begin
|
47
|
+
assert_equal Time.local(2012, 11, 5, 11, 59, 59), next_next_time.end
|
48
|
+
end
|
49
|
+
|
50
|
+
def test_pm_future
|
51
|
+
day_portion = Chronic::RepeaterDayPortion.new(:pm)
|
52
|
+
day_portion.start = @now
|
53
|
+
|
54
|
+
next_time = day_portion.next(:future)
|
55
|
+
assert_equal Time.local(2006, 8, 17, 12), next_time.begin
|
56
|
+
assert_equal Time.local(2006, 8, 17, 23, 59, 59), next_time.end
|
57
|
+
|
58
|
+
next_next_time = day_portion.next(:future)
|
59
|
+
assert_equal Time.local(2006, 8, 18, 12), next_next_time.begin
|
60
|
+
assert_equal Time.local(2006, 8, 18, 23, 59, 59), next_next_time.end
|
61
|
+
end
|
62
|
+
|
63
|
+
def test_pm_past
|
64
|
+
day_portion = Chronic::RepeaterDayPortion.new(:pm)
|
65
|
+
day_portion.start = @now
|
66
|
+
|
67
|
+
next_time = day_portion.next(:past)
|
68
|
+
assert_equal Time.local(2006, 8, 15, 12), next_time.begin
|
69
|
+
assert_equal Time.local(2006, 8, 15, 23, 59, 59), next_time.end
|
70
|
+
|
71
|
+
next_next_time = day_portion.next(:past)
|
72
|
+
assert_equal Time.local(2006, 8, 14, 12), next_next_time.begin
|
73
|
+
assert_equal Time.local(2006, 8, 14, 23, 59, 59), next_next_time.end
|
74
|
+
end
|
75
|
+
|
76
|
+
def test_pm_future_with_daylight_savings_time_boundary
|
77
|
+
@now = Time.local(2012,11,3,0,0,0)
|
78
|
+
day_portion = Chronic::RepeaterDayPortion.new(:pm)
|
79
|
+
day_portion.start = @now
|
80
|
+
|
81
|
+
next_time = day_portion.next(:future)
|
82
|
+
assert_equal Time.local(2012, 11, 3, 12), next_time.begin
|
83
|
+
assert_equal Time.local(2012, 11, 3, 23, 59, 59), next_time.end
|
84
|
+
|
85
|
+
next_next_time = day_portion.next(:future)
|
86
|
+
|
87
|
+
assert_equal Time.local(2012, 11, 4, 12), next_next_time.begin
|
88
|
+
assert_equal Time.local(2012, 11, 4, 23, 59, 59), next_next_time.end
|
89
|
+
end
|
90
|
+
|
91
|
+
def test_morning_future
|
92
|
+
day_portion = Chronic::RepeaterDayPortion.new(:morning)
|
93
|
+
day_portion.start = @now
|
94
|
+
|
95
|
+
next_time = day_portion.next(:future)
|
96
|
+
assert_equal Time.local(2006, 8, 17, 6), next_time.begin
|
97
|
+
assert_equal Time.local(2006, 8, 17, 12), next_time.end
|
98
|
+
|
99
|
+
next_next_time = day_portion.next(:future)
|
100
|
+
assert_equal Time.local(2006, 8, 18, 6), next_next_time.begin
|
101
|
+
assert_equal Time.local(2006, 8, 18, 12), next_next_time.end
|
102
|
+
end
|
103
|
+
|
104
|
+
def test_morning_past
|
105
|
+
day_portion = Chronic::RepeaterDayPortion.new(:morning)
|
106
|
+
day_portion.start = @now
|
107
|
+
|
108
|
+
next_time = day_portion.next(:past)
|
109
|
+
assert_equal Time.local(2006, 8, 16, 6), next_time.begin
|
110
|
+
assert_equal Time.local(2006, 8, 16, 12), next_time.end
|
111
|
+
|
112
|
+
next_next_time = day_portion.next(:past)
|
113
|
+
assert_equal Time.local(2006, 8, 15, 6), next_next_time.begin
|
114
|
+
assert_equal Time.local(2006, 8, 15, 12), next_next_time.end
|
115
|
+
end
|
116
|
+
|
117
|
+
def test_morning_future_with_daylight_savings_time_boundary
|
118
|
+
@now = Time.local(2012,11,3,0,0,0)
|
119
|
+
day_portion = Chronic::RepeaterDayPortion.new(:morning)
|
120
|
+
day_portion.start = @now
|
121
|
+
|
122
|
+
next_time = day_portion.next(:future)
|
123
|
+
assert_equal Time.local(2012, 11, 3, 6), next_time.begin
|
124
|
+
assert_equal Time.local(2012, 11, 3, 12), next_time.end
|
125
|
+
|
126
|
+
next_next_time = day_portion.next(:future)
|
127
|
+
|
128
|
+
assert_equal Time.local(2012, 11, 4, 6), next_next_time.begin
|
129
|
+
assert_equal Time.local(2012, 11, 4, 12), next_next_time.end
|
130
|
+
end
|
131
|
+
|
132
|
+
def test_afternoon_future
|
133
|
+
day_portion = Chronic::RepeaterDayPortion.new(:afternoon)
|
134
|
+
day_portion.start = @now
|
135
|
+
|
136
|
+
next_time = day_portion.next(:future)
|
137
|
+
assert_equal Time.local(2006, 8, 17, 13), next_time.begin
|
138
|
+
assert_equal Time.local(2006, 8, 17, 17), next_time.end
|
139
|
+
|
140
|
+
next_next_time = day_portion.next(:future)
|
141
|
+
assert_equal Time.local(2006, 8, 18, 13), next_next_time.begin
|
142
|
+
assert_equal Time.local(2006, 8, 18, 17), next_next_time.end
|
143
|
+
end
|
144
|
+
|
145
|
+
def test_afternoon_past
|
146
|
+
day_portion = Chronic::RepeaterDayPortion.new(:afternoon)
|
147
|
+
day_portion.start = @now
|
148
|
+
|
149
|
+
next_time = day_portion.next(:past)
|
150
|
+
assert_equal Time.local(2006, 8, 15, 13), next_time.begin
|
151
|
+
assert_equal Time.local(2006, 8, 15, 17), next_time.end
|
152
|
+
|
153
|
+
next_next_time = day_portion.next(:past)
|
154
|
+
assert_equal Time.local(2006, 8, 14, 13), next_next_time.begin
|
155
|
+
assert_equal Time.local(2006, 8, 14, 17), next_next_time.end
|
156
|
+
end
|
157
|
+
|
158
|
+
def test_afternoon_future_with_daylight_savings_time_boundary
|
159
|
+
@now = Time.local(2012,11,3,0,0,0)
|
160
|
+
day_portion = Chronic::RepeaterDayPortion.new(:afternoon)
|
161
|
+
day_portion.start = @now
|
162
|
+
|
163
|
+
next_time = day_portion.next(:future)
|
164
|
+
assert_equal Time.local(2012, 11, 3, 13), next_time.begin
|
165
|
+
assert_equal Time.local(2012, 11, 3, 17), next_time.end
|
166
|
+
|
167
|
+
next_next_time = day_portion.next(:future)
|
168
|
+
|
169
|
+
assert_equal Time.local(2012, 11, 4, 13), next_next_time.begin
|
170
|
+
assert_equal Time.local(2012, 11, 4, 17), next_next_time.end
|
171
|
+
end
|
172
|
+
|
173
|
+
def test_evening_future
|
174
|
+
day_portion = Chronic::RepeaterDayPortion.new(:evening)
|
175
|
+
day_portion.start = @now
|
176
|
+
|
177
|
+
next_time = day_portion.next(:future)
|
178
|
+
assert_equal Time.local(2006, 8, 16, 17), next_time.begin
|
179
|
+
assert_equal Time.local(2006, 8, 16, 20), next_time.end
|
180
|
+
|
181
|
+
next_next_time = day_portion.next(:future)
|
182
|
+
assert_equal Time.local(2006, 8, 17, 17), next_next_time.begin
|
183
|
+
assert_equal Time.local(2006, 8, 17, 20), next_next_time.end
|
184
|
+
end
|
185
|
+
|
186
|
+
def test_evening_past
|
187
|
+
day_portion = Chronic::RepeaterDayPortion.new(:evening)
|
188
|
+
day_portion.start = @now
|
189
|
+
|
190
|
+
next_time = day_portion.next(:past)
|
191
|
+
assert_equal Time.local(2006, 8, 15, 17), next_time.begin
|
192
|
+
assert_equal Time.local(2006, 8, 15, 20), next_time.end
|
193
|
+
|
194
|
+
next_next_time = day_portion.next(:past)
|
195
|
+
assert_equal Time.local(2006, 8, 14, 17), next_next_time.begin
|
196
|
+
assert_equal Time.local(2006, 8, 14, 20), next_next_time.end
|
197
|
+
end
|
198
|
+
|
199
|
+
def test_evening_future_with_daylight_savings_time_boundary
|
200
|
+
@now = Time.local(2012,11,3,0,0,0)
|
201
|
+
day_portion = Chronic::RepeaterDayPortion.new(:evening)
|
202
|
+
day_portion.start = @now
|
203
|
+
|
204
|
+
next_time = day_portion.next(:future)
|
205
|
+
assert_equal Time.local(2012, 11, 3, 17), next_time.begin
|
206
|
+
assert_equal Time.local(2012, 11, 3, 20), next_time.end
|
207
|
+
|
208
|
+
next_next_time = day_portion.next(:future)
|
209
|
+
|
210
|
+
assert_equal Time.local(2012, 11, 4, 17), next_next_time.begin
|
211
|
+
assert_equal Time.local(2012, 11, 4, 20), next_next_time.end
|
212
|
+
end
|
213
|
+
|
214
|
+
def test_night_future
|
215
|
+
day_portion = Chronic::RepeaterDayPortion.new(:night)
|
216
|
+
day_portion.start = @now
|
217
|
+
|
218
|
+
next_time = day_portion.next(:future)
|
219
|
+
assert_equal Time.local(2006, 8, 16, 20), next_time.begin
|
220
|
+
assert_equal Time.local(2006, 8, 17, 0), next_time.end
|
221
|
+
|
222
|
+
next_next_time = day_portion.next(:future)
|
223
|
+
assert_equal Time.local(2006, 8, 17, 20), next_next_time.begin
|
224
|
+
assert_equal Time.local(2006, 8, 18, 0), next_next_time.end
|
225
|
+
end
|
226
|
+
|
227
|
+
def test_night_past
|
228
|
+
day_portion = Chronic::RepeaterDayPortion.new(:night)
|
229
|
+
day_portion.start = @now
|
230
|
+
|
231
|
+
next_time = day_portion.next(:past)
|
232
|
+
assert_equal Time.local(2006, 8, 15, 20), next_time.begin
|
233
|
+
assert_equal Time.local(2006, 8, 16, 0), next_time.end
|
234
|
+
|
235
|
+
next_next_time = day_portion.next(:past)
|
236
|
+
assert_equal Time.local(2006, 8, 14, 20), next_next_time.begin
|
237
|
+
assert_equal Time.local(2006, 8, 15, 0), next_next_time.end
|
238
|
+
end
|
239
|
+
|
240
|
+
def test_night_future_with_daylight_savings_time_boundary
|
241
|
+
@now = Time.local(2012,11,3,0,0,0)
|
242
|
+
day_portion = Chronic::RepeaterDayPortion.new(:night)
|
243
|
+
day_portion.start = @now
|
244
|
+
|
245
|
+
next_time = day_portion.next(:future)
|
246
|
+
assert_equal Time.local(2012, 11, 3, 20), next_time.begin
|
247
|
+
assert_equal Time.local(2012, 11, 4, 0), next_time.end
|
248
|
+
|
249
|
+
next_next_time = day_portion.next(:future)
|
250
|
+
|
251
|
+
assert_equal Time.local(2012, 11, 4, 20), next_next_time.begin
|
252
|
+
assert_equal Time.local(2012, 11, 5, 0), next_next_time.end
|
253
|
+
end
|
254
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
class TestRepeaterFortnight < TestCase
|
4
|
+
|
5
|
+
def setup
|
6
|
+
@now = Time.local(2006, 8, 16, 14, 0, 0, 0)
|
7
|
+
end
|
8
|
+
|
9
|
+
def test_next_future
|
10
|
+
fortnights = Chronic::RepeaterFortnight.new(:fortnight)
|
11
|
+
fortnights.start = @now
|
12
|
+
|
13
|
+
next_fortnight = fortnights.next(:future)
|
14
|
+
assert_equal Time.local(2006, 8, 20), next_fortnight.begin
|
15
|
+
assert_equal Time.local(2006, 9, 3), next_fortnight.end
|
16
|
+
|
17
|
+
next_next_fortnight = fortnights.next(:future)
|
18
|
+
assert_equal Time.local(2006, 9, 3), next_next_fortnight.begin
|
19
|
+
assert_equal Time.local(2006, 9, 17), next_next_fortnight.end
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_next_past
|
23
|
+
fortnights = Chronic::RepeaterFortnight.new(:fortnight)
|
24
|
+
fortnights.start = @now
|
25
|
+
|
26
|
+
last_fortnight = fortnights.next(:past)
|
27
|
+
assert_equal Time.local(2006, 7, 30), last_fortnight.begin
|
28
|
+
assert_equal Time.local(2006, 8, 13), last_fortnight.end
|
29
|
+
|
30
|
+
last_last_fortnight = fortnights.next(:past)
|
31
|
+
assert_equal Time.local(2006, 7, 16), last_last_fortnight.begin
|
32
|
+
assert_equal Time.local(2006, 7, 30), last_last_fortnight.end
|
33
|
+
end
|
34
|
+
|
35
|
+
def test_this_future
|
36
|
+
fortnights = Chronic::RepeaterFortnight.new(:fortnight)
|
37
|
+
fortnights.start = @now
|
38
|
+
|
39
|
+
this_fortnight = fortnights.this(:future)
|
40
|
+
assert_equal Time.local(2006, 8, 16, 15), this_fortnight.begin
|
41
|
+
assert_equal Time.local(2006, 8, 27), this_fortnight.end
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_this_past
|
45
|
+
fortnights = Chronic::RepeaterFortnight.new(:fortnight)
|
46
|
+
fortnights.start = @now
|
47
|
+
|
48
|
+
this_fortnight = fortnights.this(:past)
|
49
|
+
assert_equal Time.local(2006, 8, 13, 0), this_fortnight.begin
|
50
|
+
assert_equal Time.local(2006, 8, 16, 14), this_fortnight.end
|
51
|
+
end
|
52
|
+
|
53
|
+
def test_offset
|
54
|
+
span = Chronic::Span.new(@now, @now + 1)
|
55
|
+
|
56
|
+
offset_span = Chronic::RepeaterWeek.new(:week).offset(span, 3, :future)
|
57
|
+
|
58
|
+
assert_equal Time.local(2006, 9, 6, 14), offset_span.begin
|
59
|
+
assert_equal Time.local(2006, 9, 6, 14, 0, 1), offset_span.end
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
class TestRepeaterHour < TestCase
|
4
|
+
|
5
|
+
def setup
|
6
|
+
@now = Time.local(2006, 8, 16, 14, 0, 0, 0)
|
7
|
+
end
|
8
|
+
|
9
|
+
def test_next_future
|
10
|
+
hours = Chronic::RepeaterHour.new(:hour)
|
11
|
+
hours.start = @now
|
12
|
+
|
13
|
+
next_hour = hours.next(:future)
|
14
|
+
assert_equal Time.local(2006, 8, 16, 15), next_hour.begin
|
15
|
+
assert_equal Time.local(2006, 8, 16, 16), next_hour.end
|
16
|
+
|
17
|
+
next_next_hour = hours.next(:future)
|
18
|
+
assert_equal Time.local(2006, 8, 16, 16), next_next_hour.begin
|
19
|
+
assert_equal Time.local(2006, 8, 16, 17), next_next_hour.end
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_next_past
|
23
|
+
hours = Chronic::RepeaterHour.new(:hour)
|
24
|
+
hours.start = @now
|
25
|
+
|
26
|
+
past_hour = hours.next(:past)
|
27
|
+
assert_equal Time.local(2006, 8, 16, 13), past_hour.begin
|
28
|
+
assert_equal Time.local(2006, 8, 16, 14), past_hour.end
|
29
|
+
|
30
|
+
past_past_hour = hours.next(:past)
|
31
|
+
assert_equal Time.local(2006, 8, 16, 12), past_past_hour.begin
|
32
|
+
assert_equal Time.local(2006, 8, 16, 13), past_past_hour.end
|
33
|
+
end
|
34
|
+
|
35
|
+
def test_this
|
36
|
+
@now = Time.local(2006, 8, 16, 14, 30)
|
37
|
+
|
38
|
+
hours = Chronic::RepeaterHour.new(:hour)
|
39
|
+
hours.start = @now
|
40
|
+
|
41
|
+
this_hour = hours.this(:future)
|
42
|
+
assert_equal Time.local(2006, 8, 16, 14, 31), this_hour.begin
|
43
|
+
assert_equal Time.local(2006, 8, 16, 15), this_hour.end
|
44
|
+
|
45
|
+
this_hour = hours.this(:past)
|
46
|
+
assert_equal Time.local(2006, 8, 16, 14), this_hour.begin
|
47
|
+
assert_equal Time.local(2006, 8, 16, 14, 30), this_hour.end
|
48
|
+
|
49
|
+
this_hour = hours.this(:none)
|
50
|
+
assert_equal Time.local(2006, 8, 16, 14), this_hour.begin
|
51
|
+
assert_equal Time.local(2006, 8, 16, 15), this_hour.end
|
52
|
+
end
|
53
|
+
|
54
|
+
def test_offset
|
55
|
+
span = Chronic::Span.new(@now, @now + 1)
|
56
|
+
|
57
|
+
offset_span = Chronic::RepeaterHour.new(:hour).offset(span, 3, :future)
|
58
|
+
|
59
|
+
assert_equal Time.local(2006, 8, 16, 17), offset_span.begin
|
60
|
+
assert_equal Time.local(2006, 8, 16, 17, 0, 1), offset_span.end
|
61
|
+
|
62
|
+
offset_span = Chronic::RepeaterHour.new(:hour).offset(span, 24, :past)
|
63
|
+
|
64
|
+
assert_equal Time.local(2006, 8, 15, 14), offset_span.begin
|
65
|
+
assert_equal Time.local(2006, 8, 15, 14, 0, 1), offset_span.end
|
66
|
+
end
|
67
|
+
|
68
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
class TestRepeaterMinute < TestCase
|
4
|
+
|
5
|
+
def setup
|
6
|
+
@now = Time.local(2008, 6, 25, 7, 15, 30, 0)
|
7
|
+
end
|
8
|
+
|
9
|
+
def test_next_future
|
10
|
+
minutes = Chronic::RepeaterMinute.new(:minute)
|
11
|
+
minutes.start = @now
|
12
|
+
|
13
|
+
next_minute = minutes.next(:future)
|
14
|
+
assert_equal Time.local(2008, 6, 25, 7, 16), next_minute.begin
|
15
|
+
assert_equal Time.local(2008, 6, 25, 7, 17), next_minute.end
|
16
|
+
|
17
|
+
next_next_minute = minutes.next(:future)
|
18
|
+
assert_equal Time.local(2008, 6, 25, 7, 17), next_next_minute.begin
|
19
|
+
assert_equal Time.local(2008, 6, 25, 7, 18), next_next_minute.end
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_next_past
|
23
|
+
minutes = Chronic::RepeaterMinute.new(:minute)
|
24
|
+
minutes.start = @now
|
25
|
+
|
26
|
+
prev_minute = minutes.next(:past)
|
27
|
+
assert_equal Time.local(2008, 6, 25, 7, 14), prev_minute.begin
|
28
|
+
assert_equal Time.local(2008, 6, 25, 7, 15), prev_minute.end
|
29
|
+
|
30
|
+
prev_prev_minute = minutes.next(:past)
|
31
|
+
assert_equal Time.local(2008, 6, 25, 7, 13), prev_prev_minute.begin
|
32
|
+
assert_equal Time.local(2008, 6, 25, 7, 14), prev_prev_minute.end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
class TestRepeaterMonth < TestCase
|
4
|
+
|
5
|
+
def setup
|
6
|
+
# Wed Aug 16 14:00:00 2006
|
7
|
+
@now = Time.local(2006, 8, 16, 14, 0, 0, 0)
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_offset_by
|
11
|
+
# future
|
12
|
+
|
13
|
+
time = Chronic::RepeaterMonth.new(:month).offset_by(@now, 1, :future)
|
14
|
+
assert_equal Time.local(2006, 9, 16, 14), time
|
15
|
+
|
16
|
+
time = Chronic::RepeaterMonth.new(:month).offset_by(@now, 5, :future)
|
17
|
+
assert_equal Time.local(2007, 1, 16, 14), time
|
18
|
+
|
19
|
+
# past
|
20
|
+
|
21
|
+
time = Chronic::RepeaterMonth.new(:month).offset_by(@now, 1, :past)
|
22
|
+
assert_equal Time.local(2006, 7, 16, 14), time
|
23
|
+
|
24
|
+
time = Chronic::RepeaterMonth.new(:month).offset_by(@now, 10, :past)
|
25
|
+
assert_equal Time.local(2005, 10, 16, 14), time
|
26
|
+
|
27
|
+
time = Chronic::RepeaterMonth.new(:month).offset_by(Time.local(2010, 3, 29), 1, :past)
|
28
|
+
assert_equal 2, time.month
|
29
|
+
assert_equal 28, time.day
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_offset
|
33
|
+
# future
|
34
|
+
|
35
|
+
span = Chronic::Span.new(@now, @now + 60)
|
36
|
+
offset_span = Chronic::RepeaterMonth.new(:month).offset(span, 1, :future)
|
37
|
+
|
38
|
+
assert_equal Time.local(2006, 9, 16, 14), offset_span.begin
|
39
|
+
assert_equal Time.local(2006, 9, 16, 14, 1), offset_span.end
|
40
|
+
|
41
|
+
# past
|
42
|
+
|
43
|
+
span = Chronic::Span.new(@now, @now + 60)
|
44
|
+
offset_span = Chronic::RepeaterMonth.new(:month).offset(span, 1, :past)
|
45
|
+
|
46
|
+
assert_equal Time.local(2006, 7, 16, 14), offset_span.begin
|
47
|
+
assert_equal Time.local(2006, 7, 16, 14, 1), offset_span.end
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
class TestRepeaterMonthName < TestCase
|
4
|
+
|
5
|
+
def setup
|
6
|
+
# Wed Aug 16 14:00:00 2006
|
7
|
+
@now = Time.local(2006, 8, 16, 14, 0, 0, 0)
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_next
|
11
|
+
# future
|
12
|
+
|
13
|
+
mays = Chronic::RepeaterMonthName.new(:may)
|
14
|
+
mays.start = @now
|
15
|
+
|
16
|
+
next_may = mays.next(:future)
|
17
|
+
assert_equal Time.local(2007, 5), next_may.begin
|
18
|
+
assert_equal Time.local(2007, 6), next_may.end
|
19
|
+
|
20
|
+
next_next_may = mays.next(:future)
|
21
|
+
assert_equal Time.local(2008, 5), next_next_may.begin
|
22
|
+
assert_equal Time.local(2008, 6), next_next_may.end
|
23
|
+
|
24
|
+
decembers = Chronic::RepeaterMonthName.new(:december)
|
25
|
+
decembers.start = @now
|
26
|
+
|
27
|
+
next_december = decembers.next(:future)
|
28
|
+
assert_equal Time.local(2006, 12), next_december.begin
|
29
|
+
assert_equal Time.local(2007, 1), next_december.end
|
30
|
+
|
31
|
+
# past
|
32
|
+
|
33
|
+
mays = Chronic::RepeaterMonthName.new(:may)
|
34
|
+
mays.start = @now
|
35
|
+
|
36
|
+
assert_equal Time.local(2006, 5), mays.next(:past).begin
|
37
|
+
assert_equal Time.local(2005, 5), mays.next(:past).begin
|
38
|
+
end
|
39
|
+
|
40
|
+
def test_this
|
41
|
+
octobers = Chronic::RepeaterMonthName.new(:october)
|
42
|
+
octobers.start = @now
|
43
|
+
|
44
|
+
this_october = octobers.this(:future)
|
45
|
+
assert_equal Time.local(2006, 10, 1), this_october.begin
|
46
|
+
assert_equal Time.local(2006, 11, 1), this_october.end
|
47
|
+
|
48
|
+
aprils = Chronic::RepeaterMonthName.new(:april)
|
49
|
+
aprils.start = @now
|
50
|
+
|
51
|
+
this_april = aprils.this(:past)
|
52
|
+
assert_equal Time.local(2006, 4, 1), this_april.begin
|
53
|
+
assert_equal Time.local(2006, 5, 1), this_april.end
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
class TestRepeaterSeason < TestCase
|
4
|
+
|
5
|
+
def setup
|
6
|
+
@now = Time.local(2006, 8, 16, 14, 0, 0, 0)
|
7
|
+
end
|
8
|
+
|
9
|
+
def test_next_future
|
10
|
+
seasons = Chronic::RepeaterSeason.new(:season)
|
11
|
+
seasons.start = @now
|
12
|
+
|
13
|
+
next_season = seasons.next(:future)
|
14
|
+
assert_equal Time.local(2006, 9, 23), next_season.begin
|
15
|
+
assert_equal Time.local(2006, 12, 21), next_season.end
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_next_past
|
19
|
+
seasons = Chronic::RepeaterSeason.new(:season)
|
20
|
+
seasons.start = @now
|
21
|
+
|
22
|
+
last_season = seasons.next(:past)
|
23
|
+
assert_equal Time.local(2006, 3, 20), last_season.begin
|
24
|
+
assert_equal Time.local(2006, 6, 20), last_season.end
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_this
|
28
|
+
seasons = Chronic::RepeaterSeason.new(:season)
|
29
|
+
seasons.start = @now
|
30
|
+
|
31
|
+
this_season = seasons.this(:future)
|
32
|
+
assert_equal Time.local(2006, 8, 17), this_season.begin
|
33
|
+
assert_equal Time.local(2006, 9, 22), this_season.end
|
34
|
+
|
35
|
+
this_season = seasons.this(:past)
|
36
|
+
assert_equal Time.local(2006, 6, 21), this_season.begin
|
37
|
+
assert_equal Time.local(2006, 8, 16), this_season.end
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
class TestRepeaterTime < TestCase
|
4
|
+
|
5
|
+
def setup
|
6
|
+
# Wed Aug 16 14:00:00 2006
|
7
|
+
@now = Time.local(2006, 8, 16, 14, 0, 0, 0)
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_next_future
|
11
|
+
t = Chronic::RepeaterTime.new('4:00')
|
12
|
+
t.start = @now
|
13
|
+
|
14
|
+
assert_equal Time.local(2006, 8, 16, 16), t.next(:future).begin
|
15
|
+
assert_equal Time.local(2006, 8, 17, 4), t.next(:future).begin
|
16
|
+
|
17
|
+
t = Chronic::RepeaterTime.new('13:00')
|
18
|
+
t.start = @now
|
19
|
+
|
20
|
+
assert_equal Time.local(2006, 8, 17, 13), t.next(:future).begin
|
21
|
+
assert_equal Time.local(2006, 8, 18, 13), t.next(:future).begin
|
22
|
+
|
23
|
+
t = Chronic::RepeaterTime.new('0400')
|
24
|
+
t.start = @now
|
25
|
+
|
26
|
+
assert_equal Time.local(2006, 8, 17, 4), t.next(:future).begin
|
27
|
+
assert_equal Time.local(2006, 8, 18, 4), t.next(:future).begin
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_next_past
|
31
|
+
t = Chronic::RepeaterTime.new('4:00')
|
32
|
+
t.start = @now
|
33
|
+
|
34
|
+
assert_equal Time.local(2006, 8, 16, 4), t.next(:past).begin
|
35
|
+
assert_equal Time.local(2006, 8, 15, 16), t.next(:past).begin
|
36
|
+
|
37
|
+
t = Chronic::RepeaterTime.new('13:00')
|
38
|
+
t.start = @now
|
39
|
+
|
40
|
+
assert_equal Time.local(2006, 8, 16, 13), t.next(:past).begin
|
41
|
+
assert_equal Time.local(2006, 8, 15, 13), t.next(:past).begin
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_type
|
45
|
+
t1 = Chronic::RepeaterTime.new('4')
|
46
|
+
assert_equal 14_400, t1.type.time
|
47
|
+
|
48
|
+
t1 = Chronic::RepeaterTime.new('14')
|
49
|
+
assert_equal 50_400, t1.type.time
|
50
|
+
|
51
|
+
t1 = Chronic::RepeaterTime.new('4:00')
|
52
|
+
assert_equal 14_400, t1.type.time
|
53
|
+
|
54
|
+
t1 = Chronic::RepeaterTime.new('4:30')
|
55
|
+
assert_equal 16_200, t1.type.time
|
56
|
+
|
57
|
+
t1 = Chronic::RepeaterTime.new('1400')
|
58
|
+
assert_equal 50_400, t1.type.time
|
59
|
+
|
60
|
+
t1 = Chronic::RepeaterTime.new('0400')
|
61
|
+
assert_equal 14_400, t1.type.time
|
62
|
+
|
63
|
+
t1 = Chronic::RepeaterTime.new('04')
|
64
|
+
assert_equal 14_400, t1.type.time
|
65
|
+
|
66
|
+
t1 = Chronic::RepeaterTime.new('400')
|
67
|
+
assert_equal 14_400, t1.type.time
|
68
|
+
end
|
69
|
+
|
70
|
+
end
|