Hokkaido 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (84) hide show
  1. data/Gemfile +2 -0
  2. data/Gemfile.lock +2 -2
  3. data/ansiterm-color/.gitignore +3 -0
  4. data/ansiterm-color/CHANGES +28 -0
  5. data/ansiterm-color/COPYING +340 -0
  6. data/ansiterm-color/README +137 -0
  7. data/ansiterm-color/Rakefile +88 -0
  8. data/ansiterm-color/VERSION +1 -0
  9. data/ansiterm-color/bin/cdiff +19 -0
  10. data/ansiterm-color/bin/decolor +12 -0
  11. data/ansiterm-color/doc-main.txt +119 -0
  12. data/ansiterm-color/examples/example.rb +90 -0
  13. data/ansiterm-color/install.rb +15 -0
  14. data/ansiterm-color/lib/term/ansicolor/.keep +0 -0
  15. data/ansiterm-color/lib/term/ansicolor/version.rb +10 -0
  16. data/ansiterm-color/lib/term/ansicolor.rb +102 -0
  17. data/ansiterm-color/make_doc.rb +4 -0
  18. data/ansiterm-color/tests/ansicolor_test.rb +66 -0
  19. data/chronic/.gitignore +6 -0
  20. data/chronic/HISTORY.md +205 -0
  21. data/chronic/LICENSE +21 -0
  22. data/chronic/README.md +181 -0
  23. data/chronic/Rakefile +46 -0
  24. data/chronic/chronic.gemspec +20 -0
  25. data/chronic/lib/chronic/grabber.rb +33 -0
  26. data/chronic/lib/chronic/handler.rb +88 -0
  27. data/chronic/lib/chronic/handlers.rb +572 -0
  28. data/chronic/lib/chronic/mini_date.rb +38 -0
  29. data/chronic/lib/chronic/numerizer.rb +121 -0
  30. data/chronic/lib/chronic/ordinal.rb +47 -0
  31. data/chronic/lib/chronic/pointer.rb +32 -0
  32. data/chronic/lib/chronic/repeater.rb +145 -0
  33. data/chronic/lib/chronic/repeaters/repeater_day.rb +53 -0
  34. data/chronic/lib/chronic/repeaters/repeater_day_name.rb +52 -0
  35. data/chronic/lib/chronic/repeaters/repeater_day_portion.rb +108 -0
  36. data/chronic/lib/chronic/repeaters/repeater_fortnight.rb +71 -0
  37. data/chronic/lib/chronic/repeaters/repeater_hour.rb +58 -0
  38. data/chronic/lib/chronic/repeaters/repeater_minute.rb +58 -0
  39. data/chronic/lib/chronic/repeaters/repeater_month.rb +79 -0
  40. data/chronic/lib/chronic/repeaters/repeater_month_name.rb +94 -0
  41. data/chronic/lib/chronic/repeaters/repeater_season.rb +109 -0
  42. data/chronic/lib/chronic/repeaters/repeater_season_name.rb +43 -0
  43. data/chronic/lib/chronic/repeaters/repeater_second.rb +42 -0
  44. data/chronic/lib/chronic/repeaters/repeater_time.rb +128 -0
  45. data/chronic/lib/chronic/repeaters/repeater_week.rb +74 -0
  46. data/chronic/lib/chronic/repeaters/repeater_weekday.rb +85 -0
  47. data/chronic/lib/chronic/repeaters/repeater_weekend.rb +66 -0
  48. data/chronic/lib/chronic/repeaters/repeater_year.rb +77 -0
  49. data/chronic/lib/chronic/scalar.rb +116 -0
  50. data/chronic/lib/chronic/season.rb +26 -0
  51. data/chronic/lib/chronic/separator.rb +94 -0
  52. data/chronic/lib/chronic/span.rb +31 -0
  53. data/chronic/lib/chronic/tag.rb +36 -0
  54. data/chronic/lib/chronic/time_zone.rb +32 -0
  55. data/chronic/lib/chronic/token.rb +47 -0
  56. data/chronic/lib/chronic.rb +442 -0
  57. data/chronic/test/helper.rb +12 -0
  58. data/chronic/test/test_chronic.rb +150 -0
  59. data/chronic/test/test_daylight_savings.rb +118 -0
  60. data/chronic/test/test_handler.rb +104 -0
  61. data/chronic/test/test_mini_date.rb +32 -0
  62. data/chronic/test/test_numerizer.rb +72 -0
  63. data/chronic/test/test_parsing.rb +1061 -0
  64. data/chronic/test/test_repeater_day_name.rb +51 -0
  65. data/chronic/test/test_repeater_day_portion.rb +254 -0
  66. data/chronic/test/test_repeater_fortnight.rb +62 -0
  67. data/chronic/test/test_repeater_hour.rb +68 -0
  68. data/chronic/test/test_repeater_minute.rb +34 -0
  69. data/chronic/test/test_repeater_month.rb +50 -0
  70. data/chronic/test/test_repeater_month_name.rb +56 -0
  71. data/chronic/test/test_repeater_season.rb +40 -0
  72. data/chronic/test/test_repeater_time.rb +70 -0
  73. data/chronic/test/test_repeater_week.rb +62 -0
  74. data/chronic/test/test_repeater_weekday.rb +55 -0
  75. data/chronic/test/test_repeater_weekend.rb +74 -0
  76. data/chronic/test/test_repeater_year.rb +69 -0
  77. data/chronic/test/test_span.rb +23 -0
  78. data/chronic/test/test_token.rb +25 -0
  79. data/lib/Hokkaido/version.rb +1 -1
  80. data/lib/Hokkaido.rb +13 -9
  81. data/lib/gem_modifier.rb +23 -3
  82. data/lib/term/ansicolor.rb +4 -1
  83. data/spec/Hokkaido/port_spec.rb +15 -7
  84. metadata +78 -2
@@ -0,0 +1,1061 @@
1
+ require 'helper'
2
+
3
+ class TestParsing < TestCase
4
+ # Wed Aug 16 14:00:00 UTC 2006
5
+ TIME_2006_08_16_14_00_00 = Time.local(2006, 8, 16, 14, 0, 0, 0)
6
+
7
+ def setup
8
+ @time_2006_08_16_14_00_00 = TIME_2006_08_16_14_00_00
9
+ end
10
+
11
+ def test_handle_generic
12
+ time = Chronic.parse("2012-08-02T13:00:00")
13
+ assert_equal Time.local(2012, 8, 2, 13), time
14
+
15
+ time = Chronic.parse("2012-08-02T13:00:00+01:00")
16
+ assert_equal Time.utc(2012, 8, 2, 12), time
17
+
18
+ time = Chronic.parse("2012-08-02T08:00:00-04:00")
19
+ assert_equal Time.utc(2012, 8, 2, 12), time
20
+
21
+ time = Chronic.parse("2012-08-02T12:00:00Z")
22
+ assert_equal Time.utc(2012, 8, 2, 12), time
23
+
24
+ time = Chronic.parse("2012-01-03 01:00:00.100")
25
+ time2 = Time.parse("2012-01-03 01:00:00.100")
26
+ assert_equal time, time2
27
+ end
28
+
29
+ def test_handle_rmn_sd
30
+ time = parse_now("aug 3")
31
+ assert_equal Time.local(2006, 8, 3, 12), time
32
+
33
+ time = parse_now("aug 3", :context => :past)
34
+ assert_equal Time.local(2006, 8, 3, 12), time
35
+
36
+ time = parse_now("aug 20")
37
+ assert_equal Time.local(2006, 8, 20, 12), time
38
+
39
+ time = parse_now("aug 20", :context => :future)
40
+ assert_equal Time.local(2006, 8, 20, 12), time
41
+
42
+ time = parse_now("may 27")
43
+ assert_equal Time.local(2007, 5, 27, 12), time
44
+
45
+ time = parse_now("may 28", :context => :past)
46
+ assert_equal Time.local(2006, 5, 28, 12), time
47
+
48
+ time = parse_now("may 28 5pm", :context => :past)
49
+ assert_equal Time.local(2006, 5, 28, 17), time
50
+
51
+ time = parse_now("may 28 at 5pm", :context => :past)
52
+ assert_equal Time.local(2006, 5, 28, 17), time
53
+
54
+ time = parse_now("may 28 at 5:32.19pm", :context => :past)
55
+ assert_equal Time.local(2006, 5, 28, 17, 32, 19), time
56
+ end
57
+
58
+ def test_handle_rmn_sd_on
59
+ time = parse_now("5pm on may 28")
60
+ assert_equal Time.local(2007, 5, 28, 17), time
61
+
62
+ time = parse_now("5pm may 28")
63
+ assert_equal Time.local(2007, 5, 28, 17), time
64
+
65
+ time = parse_now("5 on may 28", :ambiguous_time_range => :none)
66
+ assert_equal Time.local(2007, 5, 28, 05), time
67
+ end
68
+
69
+ def test_handle_rmn_od
70
+ time = parse_now("may 27th")
71
+ assert_equal Time.local(2007, 5, 27, 12), time
72
+
73
+ time = parse_now("may 27th", :context => :past)
74
+ assert_equal Time.local(2006, 5, 27, 12), time
75
+
76
+ time = parse_now("may 27th 5:00 pm", :context => :past)
77
+ assert_equal Time.local(2006, 5, 27, 17), time
78
+
79
+ time = parse_now("may 27th at 5pm", :context => :past)
80
+ assert_equal Time.local(2006, 5, 27, 17), time
81
+
82
+ time = parse_now("may 27th at 5", :ambiguous_time_range => :none)
83
+ assert_equal Time.local(2007, 5, 27, 5), time
84
+ end
85
+
86
+ def test_handle_od_rm
87
+ time = parse_now("fifteenth of this month")
88
+ assert_equal Time.local(2006, 8, 15, 12), time
89
+ end
90
+
91
+ def test_handle_od_rmn
92
+ time = parse_now("22nd February")
93
+ assert_equal Time.local(2007, 2, 22, 12), time
94
+
95
+ time = parse_now("31st of may at 6:30pm")
96
+ assert_equal Time.local(2007, 5, 31, 18, 30), time
97
+
98
+ time = parse_now("11th december 8am")
99
+ assert_equal Time.local(2006, 12, 11, 8), time
100
+ end
101
+
102
+ def test_handle_sy_rmn_od
103
+ time = parse_now("2009 May 22nd")
104
+ assert_equal Time.local(2009, 05, 22, 12), time
105
+ end
106
+
107
+ def test_handle_sd_rmn
108
+ time = parse_now("22 February")
109
+ assert_equal Time.local(2007, 2, 22, 12), time
110
+
111
+ time = parse_now("31 of may at 6:30pm")
112
+ assert_equal Time.local(2007, 5, 31, 18, 30), time
113
+
114
+ time = parse_now("11 december 8am")
115
+ assert_equal Time.local(2006, 12, 11, 8), time
116
+ end
117
+
118
+ def test_handle_rmn_od_on
119
+ time = parse_now("5:00 pm may 27th", :context => :past)
120
+ assert_equal Time.local(2006, 5, 27, 17), time
121
+
122
+ time = parse_now("05:00 pm may 27th", :context => :past)
123
+ assert_equal Time.local(2006, 5, 27, 17), time
124
+
125
+ time = parse_now("5pm on may 27th", :context => :past)
126
+ assert_equal Time.local(2006, 5, 27, 17), time
127
+
128
+ time = parse_now("5 on may 27th", :ambiguous_time_range => :none)
129
+ assert_equal Time.local(2007, 5, 27, 5), time
130
+ end
131
+
132
+ def test_handle_rmn_sy
133
+ time = parse_now("may 97")
134
+ assert_equal Time.local(1997, 5, 16, 12), time
135
+
136
+ time = parse_now("may 33", :ambiguous_year_future_bias => 10)
137
+ assert_equal Time.local(2033, 5, 16, 12), time
138
+
139
+ time = parse_now("may 32")
140
+ assert_equal Time.local(2032, 5, 16, 12, 0, 0), time
141
+ end
142
+
143
+ def test_handle_rdn_rmn_sd_t_tz_sy
144
+ time = parse_now("Mon Apr 02 17:00:00 PDT 2007")
145
+ assert_equal 1175558400, time.to_i
146
+ end
147
+
148
+ def test_handle_sy_sm_sd_t_tz
149
+ time = parse_now("2011-07-03 22:11:35 +0100")
150
+ assert_equal 1309727495, time.to_i
151
+
152
+ time = parse_now("2011-07-03 22:11:35 +01:00")
153
+ assert_equal 1309727495, time.to_i
154
+
155
+ time = parse_now("2011-07-03 21:11:35 UTC")
156
+ assert_equal 1309727495, time.to_i
157
+ end
158
+
159
+ def test_handle_rmn_sd_sy
160
+ time = parse_now("November 18, 2010")
161
+ assert_equal Time.local(2010, 11, 18, 12), time
162
+
163
+ time = parse_now("Jan 1,2010")
164
+ assert_equal Time.local(2010, 1, 1, 12), time
165
+
166
+ time = parse_now("February 14, 2004")
167
+ assert_equal Time.local(2004, 2, 14, 12), time
168
+
169
+ time = parse_now("jan 3 2010")
170
+ assert_equal Time.local(2010, 1, 3, 12), time
171
+
172
+ time = parse_now("jan 3 2010 midnight")
173
+ assert_equal Time.local(2010, 1, 4, 0), time
174
+
175
+ time = parse_now("jan 3 2010 at midnight")
176
+ assert_equal Time.local(2010, 1, 4, 0), time
177
+
178
+ time = parse_now("jan 3 2010 at 4", :ambiguous_time_range => :none)
179
+ assert_equal Time.local(2010, 1, 3, 4), time
180
+
181
+ time = parse_now("may 27, 1979")
182
+ assert_equal Time.local(1979, 5, 27, 12), time
183
+
184
+ time = parse_now("may 27 79")
185
+ assert_equal Time.local(1979, 5, 27, 12), time
186
+
187
+ time = parse_now("may 27 79 4:30")
188
+ assert_equal Time.local(1979, 5, 27, 16, 30), time
189
+
190
+ time = parse_now("may 27 79 at 4:30", :ambiguous_time_range => :none)
191
+ assert_equal Time.local(1979, 5, 27, 4, 30), time
192
+
193
+ time = parse_now("may 27 32")
194
+ assert_equal Time.local(2032, 5, 27, 12, 0, 0), time
195
+ end
196
+
197
+ def test_handle_rmn_od_sy
198
+ time = parse_now("may 1st 01")
199
+ assert_equal Time.local(2001, 5, 1, 12), time
200
+
201
+ time = parse_now("November 18th 2010")
202
+ assert_equal Time.local(2010, 11, 18, 12), time
203
+
204
+ time = parse_now("November 18th, 2010")
205
+ assert_equal Time.local(2010, 11, 18, 12), time
206
+
207
+ time = parse_now("November 18th 2010 midnight")
208
+ assert_equal Time.local(2010, 11, 19, 0), time
209
+
210
+ time = parse_now("November 18th 2010 at midnight")
211
+ assert_equal Time.local(2010, 11, 19, 0), time
212
+
213
+ time = parse_now("November 18th 2010 at 4")
214
+ assert_equal Time.local(2010, 11, 18, 16), time
215
+
216
+ time = parse_now("November 18th 2010 at 4", :ambiguous_time_range => :none)
217
+ assert_equal Time.local(2010, 11, 18, 4), time
218
+
219
+ time = parse_now("March 30th, 1979")
220
+ assert_equal Time.local(1979, 3, 30, 12), time
221
+
222
+ time = parse_now("March 30th 79")
223
+ assert_equal Time.local(1979, 3, 30, 12), time
224
+
225
+ time = parse_now("March 30th 79 4:30")
226
+ assert_equal Time.local(1979, 3, 30, 16, 30), time
227
+
228
+ time = parse_now("March 30th 79 at 4:30", :ambiguous_time_range => :none)
229
+ assert_equal Time.local(1979, 3, 30, 4, 30), time
230
+ end
231
+
232
+ def test_handle_od_rmn_sy
233
+ time = parse_now("22nd February 2012")
234
+ assert_equal Time.local(2012, 2, 22, 12), time
235
+
236
+ time = parse_now("11th december 79")
237
+ assert_equal Time.local(1979, 12, 11, 12), time
238
+ end
239
+
240
+ def test_handle_sd_rmn_sy
241
+ time = parse_now("3 jan 2010")
242
+ assert_equal Time.local(2010, 1, 3, 12), time
243
+
244
+ time = parse_now("3 jan 2010 4pm")
245
+ assert_equal Time.local(2010, 1, 3, 16), time
246
+
247
+ time = parse_now("27 Oct 2006 7:30pm")
248
+ assert_equal Time.local(2006, 10, 27, 19, 30), time
249
+ end
250
+
251
+ def test_handle_sm_sd_sy
252
+ time = parse_now("5/27/1979")
253
+ assert_equal Time.local(1979, 5, 27, 12), time
254
+
255
+ time = parse_now("5/27/1979 4am")
256
+ assert_equal Time.local(1979, 5, 27, 4), time
257
+
258
+ time = parse_now("7/12/11")
259
+ assert_equal Time.local(2011, 7, 12, 12), time
260
+
261
+ time = parse_now("7/12/11", :endian_precedence => :little)
262
+ assert_equal Time.local(2011, 12, 7, 12), time
263
+
264
+ time = parse_now("9/19/2011 6:05:57 PM")
265
+ assert_equal Time.local(2011, 9, 19, 18, 05, 57), time
266
+
267
+ # month day overflows
268
+ time = parse_now("30/2/2000")
269
+ assert_nil time
270
+ end
271
+
272
+ def test_handle_sd_sm_sy
273
+ time = parse_now("27/5/1979")
274
+ assert_equal Time.local(1979, 5, 27, 12), time
275
+
276
+ time = parse_now("27/5/1979 @ 0700")
277
+ assert_equal Time.local(1979, 5, 27, 7), time
278
+
279
+ time = parse_now("03/18/2012 09:26 pm")
280
+ assert_equal Time.local(2012, 3, 18, 21, 26), time
281
+ end
282
+
283
+ def test_handle_sy_sm_sd
284
+ time = parse_now("2000-1-1")
285
+ assert_equal Time.local(2000, 1, 1, 12), time
286
+
287
+ time = parse_now("2006-08-20")
288
+ assert_equal Time.local(2006, 8, 20, 12), time
289
+
290
+ time = parse_now("2006-08-20 7pm")
291
+ assert_equal Time.local(2006, 8, 20, 19), time
292
+
293
+ time = parse_now("2006-08-20 03:00")
294
+ assert_equal Time.local(2006, 8, 20, 3), time
295
+
296
+ time = parse_now("2006-08-20 03:30:30")
297
+ assert_equal Time.local(2006, 8, 20, 3, 30, 30), time
298
+
299
+ time = parse_now("2006-08-20 15:30:30")
300
+ assert_equal Time.local(2006, 8, 20, 15, 30, 30), time
301
+
302
+ time = parse_now("2006-08-20 15:30.30")
303
+ assert_equal Time.local(2006, 8, 20, 15, 30, 30), time
304
+
305
+ time = parse_now("1902-08-20")
306
+ assert_equal Time.local(1902, 8, 20, 12, 0, 0), time
307
+
308
+ # exif date time original
309
+ time = parse_now("2012:05:25 22:06:50")
310
+ assert_equal Time.local(2012, 5, 25, 22, 6, 50), time
311
+ end
312
+
313
+ def test_handle_sm_sd
314
+ time = parse_now("05/06")
315
+ assert_equal Time.local(2006, 5, 6, 12), time
316
+
317
+ time = parse_now("05/06", :endian_precedence => [:little, :medium])
318
+ assert_equal Time.local(2006, 6, 5, 12), time
319
+
320
+ time = parse_now("05/06 6:05:57 PM")
321
+ assert_equal Time.local(2006, 5, 6, 18, 05, 57), time
322
+
323
+ time = parse_now("05/06 6:05:57 PM", :endian_precedence => [:little, :medium])
324
+ assert_equal Time.local(2006, 6, 5, 18, 05, 57), time
325
+
326
+ time = parse_now("13/01")
327
+ assert_equal Time.local(2006, 1, 13, 12), time
328
+ end
329
+
330
+ # def test_handle_sm_sy
331
+ # time = parse_now("05/06")
332
+ # assert_equal Time.local(2006, 5, 16, 12), time
333
+ #
334
+ # time = parse_now("12/06")
335
+ # assert_equal Time.local(2006, 12, 16, 12), time
336
+ #
337
+ # time = parse_now("13/06")
338
+ # assert_equal nil, time
339
+ # end
340
+
341
+ def test_handle_r
342
+ time = parse_now("9am on Saturday")
343
+ assert_equal Time.local(2006, 8, 19, 9), time
344
+
345
+ time = parse_now("on Tuesday")
346
+ assert_equal Time.local(2006, 8, 22, 12), time
347
+ end
348
+
349
+ def test_handle_r_g_r
350
+ end
351
+
352
+ def test_handle_srp
353
+ end
354
+
355
+ def test_handle_s_r_p
356
+ end
357
+
358
+ def test_handle_p_s_r
359
+ end
360
+
361
+ def test_handle_s_r_p_a
362
+ time1 = parse_now("two days ago 0:0:0am")
363
+ time2 = parse_now("two days ago 00:00:00am")
364
+ assert_equal time1, time2
365
+ end
366
+
367
+ def test_handle_orr
368
+ time = parse_now("5th tuesday in january")
369
+ assert_equal Time.local(2007, 01, 30, 12), time
370
+
371
+ time = parse_now("5th tuesday in february")
372
+ assert_equal nil, time
373
+
374
+ %W(jan feb march april may june july aug sep oct nov dec).each_with_index do |month, index|
375
+ time = parse_now("5th tuesday in #{month}")
376
+
377
+ if time then
378
+ assert_equal time.month, index+1
379
+ end
380
+ end
381
+ end
382
+
383
+ def test_handle_o_r_s_r
384
+ time = parse_now("3rd wednesday in november")
385
+ assert_equal Time.local(2006, 11, 15, 12), time
386
+
387
+ time = parse_now("10th wednesday in november")
388
+ assert_equal nil, time
389
+
390
+ # time = parse_now("3rd wednesday in 2007")
391
+ # assert_equal Time.local(2007, 1, 20, 12), time
392
+ end
393
+
394
+ def test_handle_o_r_g_r
395
+ time = parse_now("3rd month next year", :guess => false)
396
+ assert_equal Time.local(2007, 3), time.begin
397
+
398
+ time = parse_now("3rd month next year", :guess => false)
399
+ assert_equal Time.local(2007, 3, 1), time.begin
400
+
401
+ time = parse_now("3rd thursday this september")
402
+ assert_equal Time.local(2006, 9, 21, 12), time
403
+
404
+ now = Time.parse("1/10/2010")
405
+ time = parse_now("3rd thursday this november", :now => now)
406
+ assert_equal Time.local(2010, 11, 18, 12), time
407
+
408
+ time = parse_now("4th day last week")
409
+ assert_equal Time.local(2006, 8, 9, 12), time
410
+ end
411
+
412
+ def test_handle_sm_rmn_sy
413
+ time = parse_now('30-Mar-11')
414
+ assert_equal Time.local(2011, 3, 30, 12), time
415
+ end
416
+
417
+ # end of testing handlers
418
+
419
+ def test_parse_guess_r
420
+ time = parse_now("friday")
421
+ assert_equal Time.local(2006, 8, 18, 12), time
422
+
423
+ time = parse_now("tue")
424
+ assert_equal Time.local(2006, 8, 22, 12), time
425
+
426
+ time = parse_now("5")
427
+ assert_equal Time.local(2006, 8, 16, 17), time
428
+
429
+ time = Chronic.parse("5", :now => Time.local(2006, 8, 16, 3, 0, 0, 0), :ambiguous_time_range => :none)
430
+ assert_equal Time.local(2006, 8, 16, 5), time
431
+
432
+ time = parse_now("13:00")
433
+ assert_equal Time.local(2006, 8, 17, 13), time
434
+
435
+ time = parse_now("13:45")
436
+ assert_equal Time.local(2006, 8, 17, 13, 45), time
437
+
438
+ time = parse_now("1:01pm")
439
+ assert_equal Time.local(2006, 8, 16, 13, 01), time
440
+
441
+ time = parse_now("2:01pm")
442
+ assert_equal Time.local(2006, 8, 16, 14, 01), time
443
+
444
+ time = parse_now("november")
445
+ assert_equal Time.local(2006, 11, 16), time
446
+ end
447
+
448
+ def test_parse_guess_rr
449
+ time = parse_now("friday 13:00")
450
+ assert_equal Time.local(2006, 8, 18, 13), time
451
+
452
+ time = parse_now("monday 4:00")
453
+ assert_equal Time.local(2006, 8, 21, 16), time
454
+
455
+ time = parse_now("sat 4:00", :ambiguous_time_range => :none)
456
+ assert_equal Time.local(2006, 8, 19, 4), time
457
+
458
+ time = parse_now("sunday 4:20", :ambiguous_time_range => :none)
459
+ assert_equal Time.local(2006, 8, 20, 4, 20), time
460
+
461
+ time = parse_now("4 pm")
462
+ assert_equal Time.local(2006, 8, 16, 16), time
463
+
464
+ time = parse_now("4 am", :ambiguous_time_range => :none)
465
+ assert_equal Time.local(2006, 8, 16, 4), time
466
+
467
+ time = parse_now("12 pm")
468
+ assert_equal Time.local(2006, 8, 16, 12), time
469
+
470
+ time = parse_now("12:01 pm")
471
+ assert_equal Time.local(2006, 8, 16, 12, 1), time
472
+
473
+ time = parse_now("12:01 am")
474
+ assert_equal Time.local(2006, 8, 16, 0, 1), time
475
+
476
+ time = parse_now("12 am")
477
+ assert_equal Time.local(2006, 8, 16), time
478
+
479
+ time = parse_now("4:00 in the morning")
480
+ assert_equal Time.local(2006, 8, 16, 4), time
481
+
482
+ time = parse_now("0:10")
483
+ assert_equal Time.local(2006, 8, 17, 0, 10), time
484
+
485
+ time = parse_now("november 4")
486
+ assert_equal Time.local(2006, 11, 4, 12), time
487
+
488
+ time = parse_now("aug 24")
489
+ assert_equal Time.local(2006, 8, 24, 12), time
490
+ end
491
+
492
+ def test_parse_guess_rrr
493
+ time = parse_now("friday 1 pm")
494
+ assert_equal Time.local(2006, 8, 18, 13), time
495
+
496
+ time = parse_now("friday 11 at night")
497
+ assert_equal Time.local(2006, 8, 18, 23), time
498
+
499
+ time = parse_now("friday 11 in the evening")
500
+ assert_equal Time.local(2006, 8, 18, 23), time
501
+
502
+ time = parse_now("sunday 6am")
503
+ assert_equal Time.local(2006, 8, 20, 6), time
504
+
505
+ time = parse_now("friday evening at 7")
506
+ assert_equal Time.local(2006, 8, 18, 19), time
507
+ end
508
+
509
+ def test_parse_guess_gr
510
+ # year
511
+
512
+ time = parse_now("this year", :guess => false)
513
+ assert_equal Time.local(2006, 8, 17), time.begin
514
+
515
+ time = parse_now("this year", :context => :past, :guess => false)
516
+ assert_equal Time.local(2006, 1, 1), time.begin
517
+
518
+ # month
519
+
520
+ time = parse_now("this month")
521
+ assert_equal Time.local(2006, 8, 24, 12), time
522
+
523
+ time = parse_now("this month", :context => :past)
524
+ assert_equal Time.local(2006, 8, 8, 12), time
525
+
526
+ time = Chronic.parse("next month", :now => Time.local(2006, 11, 15))
527
+ assert_equal Time.local(2006, 12, 16, 12), time
528
+
529
+ # month name
530
+
531
+ time = parse_now("last november")
532
+ assert_equal Time.local(2005, 11, 16), time
533
+
534
+ # fortnight
535
+
536
+ time = parse_now("this fortnight")
537
+ assert_equal Time.local(2006, 8, 21, 19, 30), time
538
+
539
+ time = parse_now("this fortnight", :context => :past)
540
+ assert_equal Time.local(2006, 8, 14, 19), time
541
+
542
+ # week
543
+
544
+ time = parse_now("this week")
545
+ assert_equal Time.local(2006, 8, 18, 7, 30), time
546
+
547
+ time = parse_now("this week", :context => :past)
548
+ assert_equal Time.local(2006, 8, 14, 19), time
549
+
550
+ # weekend
551
+
552
+ time = parse_now("this weekend")
553
+ assert_equal Time.local(2006, 8, 20), time
554
+
555
+ time = parse_now("this weekend", :context => :past)
556
+ assert_equal Time.local(2006, 8, 13), time
557
+
558
+ time = parse_now("last weekend")
559
+ assert_equal Time.local(2006, 8, 13), time
560
+
561
+ # day
562
+
563
+ time = parse_now("this day")
564
+ assert_equal Time.local(2006, 8, 16, 19), time
565
+
566
+ time = parse_now("this day", :context => :past)
567
+ assert_equal Time.local(2006, 8, 16, 7), time
568
+
569
+ time = parse_now("today")
570
+ assert_equal Time.local(2006, 8, 16, 19), time
571
+
572
+ time = parse_now("yesterday")
573
+ assert_equal Time.local(2006, 8, 15, 12), time
574
+
575
+ now = Time.parse("2011-05-27 23:10") # after 11pm
576
+ time = parse_now("yesterday", :now => now)
577
+ assert_equal Time.local(2011, 05, 26, 12), time
578
+
579
+ time = parse_now("tomorrow")
580
+ assert_equal Time.local(2006, 8, 17, 12), time
581
+
582
+ # day name
583
+
584
+ time = parse_now("this tuesday")
585
+ assert_equal Time.local(2006, 8, 22, 12), time
586
+
587
+ time = parse_now("next tuesday")
588
+ assert_equal Time.local(2006, 8, 22, 12), time
589
+
590
+ time = parse_now("last tuesday")
591
+ assert_equal Time.local(2006, 8, 15, 12), time
592
+
593
+ time = parse_now("this wed")
594
+ assert_equal Time.local(2006, 8, 23, 12), time
595
+
596
+ time = parse_now("next wed")
597
+ assert_equal Time.local(2006, 8, 23, 12), time
598
+
599
+ time = parse_now("last wed")
600
+ assert_equal Time.local(2006, 8, 9, 12), time
601
+
602
+ monday = Time.local(2006, 8, 21, 12)
603
+ assert_equal monday, parse_now("mon")
604
+ assert_equal monday, parse_now("mun")
605
+
606
+ tuesday = Time.local(2006, 8, 22, 12)
607
+ assert_equal tuesday, parse_now("tue")
608
+ assert_equal tuesday, parse_now("tus")
609
+
610
+ wednesday = Time.local(2006, 8, 23, 12)
611
+ assert_equal wednesday, parse_now("wed")
612
+ assert_equal wednesday, parse_now("wenns")
613
+
614
+ thursday = Time.local(2006, 8, 17, 12)
615
+ assert_equal thursday, parse_now("thu")
616
+ assert_equal thursday, parse_now("thur")
617
+
618
+ friday = Time.local(2006, 8, 18, 12)
619
+ assert_equal friday, parse_now("fri")
620
+ assert_equal friday, parse_now("fry")
621
+
622
+ saturday = Time.local(2006, 8, 19, 12)
623
+ assert_equal saturday, parse_now("sat")
624
+ assert_equal saturday, parse_now("satterday")
625
+
626
+ sunday = Time.local(2006, 8, 20, 12)
627
+ assert_equal sunday, parse_now("sun")
628
+ assert_equal sunday, parse_now("sum")
629
+
630
+ # day portion
631
+
632
+ time = parse_now("this morning")
633
+ assert_equal Time.local(2006, 8, 16, 9), time
634
+
635
+ time = parse_now("tonight")
636
+ assert_equal Time.local(2006, 8, 16, 22), time
637
+
638
+ # hour
639
+
640
+ time = parse_now("next hr")
641
+ assert_equal Time.local(2006, 8, 16, 15, 30, 0), time
642
+
643
+ time = parse_now("next hrs")
644
+ assert_equal Time.local(2006, 8, 16, 15, 30, 0), time
645
+
646
+ # minute
647
+
648
+ time = parse_now("next min")
649
+ assert_equal Time.local(2006, 8, 16, 14, 1, 30), time
650
+
651
+ time = parse_now("next mins")
652
+ assert_equal Time.local(2006, 8, 16, 14, 1, 30), time
653
+
654
+ time = parse_now("next minute")
655
+ assert_equal Time.local(2006, 8, 16, 14, 1, 30), time
656
+
657
+ # second
658
+
659
+ time = parse_now("next sec")
660
+ assert_equal Time.local(2006, 8, 16, 14, 0, 1), time
661
+
662
+ time = parse_now("next secs")
663
+ assert_equal Time.local(2006, 8, 16, 14, 0, 1), time
664
+
665
+ time = parse_now("this second")
666
+ assert_equal Time.local(2006, 8, 16, 14), time
667
+
668
+ time = parse_now("this second", :context => :past)
669
+ assert_equal Time.local(2006, 8, 16, 14), time
670
+
671
+ time = parse_now("next second")
672
+ assert_equal Time.local(2006, 8, 16, 14, 0, 1), time
673
+
674
+ time = parse_now("last second")
675
+ assert_equal Time.local(2006, 8, 16, 13, 59, 59), time
676
+ end
677
+
678
+ def test_parse_guess_grr
679
+ time = parse_now("yesterday at 4:00")
680
+ assert_equal Time.local(2006, 8, 15, 16), time
681
+
682
+ time = parse_now("today at 9:00")
683
+ assert_equal Time.local(2006, 8, 16, 9), time
684
+
685
+ time = parse_now("today at 2100")
686
+ assert_equal Time.local(2006, 8, 16, 21), time
687
+
688
+ time = parse_now("this day at 0900")
689
+ assert_equal Time.local(2006, 8, 16, 9), time
690
+
691
+ time = parse_now("tomorrow at 0900")
692
+ assert_equal Time.local(2006, 8, 17, 9), time
693
+
694
+ time = parse_now("yesterday at 4:00", :ambiguous_time_range => :none)
695
+ assert_equal Time.local(2006, 8, 15, 4), time
696
+
697
+ time = parse_now("last friday at 4:00")
698
+ assert_equal Time.local(2006, 8, 11, 16), time
699
+
700
+ time = parse_now("next wed 4:00")
701
+ assert_equal Time.local(2006, 8, 23, 16), time
702
+
703
+ time = parse_now("yesterday afternoon")
704
+ assert_equal Time.local(2006, 8, 15, 15), time
705
+
706
+ time = parse_now("last week tuesday")
707
+ assert_equal Time.local(2006, 8, 8, 12), time
708
+
709
+ time = parse_now("tonight at 7")
710
+ assert_equal Time.local(2006, 8, 16, 19), time
711
+
712
+ time = parse_now("tonight 7")
713
+ assert_equal Time.local(2006, 8, 16, 19), time
714
+
715
+ time = parse_now("7 tonight")
716
+ assert_equal Time.local(2006, 8, 16, 19), time
717
+ end
718
+
719
+ def test_parse_guess_grrr
720
+ time = parse_now("today at 6:00pm")
721
+ assert_equal Time.local(2006, 8, 16, 18), time
722
+
723
+ time = parse_now("today at 6:00am")
724
+ assert_equal Time.local(2006, 8, 16, 6), time
725
+
726
+ time = parse_now("this day 1800")
727
+ assert_equal Time.local(2006, 8, 16, 18), time
728
+
729
+ time = parse_now("yesterday at 4:00pm")
730
+ assert_equal Time.local(2006, 8, 15, 16), time
731
+
732
+ time = parse_now("tomorrow evening at 7")
733
+ assert_equal Time.local(2006, 8, 17, 19), time
734
+
735
+ time = parse_now("tomorrow morning at 5:30")
736
+ assert_equal Time.local(2006, 8, 17, 5, 30), time
737
+
738
+ time = parse_now("next monday at 12:01 am")
739
+ assert_equal Time.local(2006, 8, 21, 00, 1), time
740
+
741
+ time = parse_now("next monday at 12:01 pm")
742
+ assert_equal Time.local(2006, 8, 21, 12, 1), time
743
+
744
+ # with context
745
+ time = parse_now("sunday at 8:15pm", :context => :past)
746
+ assert_equal Time.local(2006, 8, 13, 20, 15), time
747
+ end
748
+
749
+ def test_parse_guess_rgr
750
+ time = parse_now("afternoon yesterday")
751
+ assert_equal Time.local(2006, 8, 15, 15), time
752
+
753
+ time = parse_now("tuesday last week")
754
+ assert_equal Time.local(2006, 8, 8, 12), time
755
+ end
756
+
757
+ def test_parse_guess_a_ago
758
+ time = parse_now("AN hour ago")
759
+ assert_equal Time.local(2006, 8, 16, 13), time
760
+
761
+ time = parse_now("A day ago")
762
+ assert_equal Time.local(2006, 8, 15, 14), time
763
+
764
+ time = parse_now("a month ago")
765
+ assert_equal Time.local(2006, 7, 16, 14), time
766
+
767
+ time = parse_now("a year ago")
768
+ assert_equal Time.local(2005, 8, 16, 14), time
769
+ end
770
+
771
+ def test_parse_guess_s_r_p
772
+ # past
773
+
774
+ time = parse_now("3 years ago")
775
+ assert_equal Time.local(2003, 8, 16, 14), time
776
+
777
+ time = parse_now("1 month ago")
778
+ assert_equal Time.local(2006, 7, 16, 14), time
779
+
780
+ time = parse_now("1 fortnight ago")
781
+ assert_equal Time.local(2006, 8, 2, 14), time
782
+
783
+ time = parse_now("2 fortnights ago")
784
+ assert_equal Time.local(2006, 7, 19, 14), time
785
+
786
+ time = parse_now("3 weeks ago")
787
+ assert_equal Time.local(2006, 7, 26, 14), time
788
+
789
+ time = parse_now("2 weekends ago")
790
+ assert_equal Time.local(2006, 8, 5), time
791
+
792
+ time = parse_now("3 days ago")
793
+ assert_equal Time.local(2006, 8, 13, 14), time
794
+
795
+ #time = parse_now("1 monday ago")
796
+ #assert_equal Time.local(2006, 8, 14, 12), time
797
+
798
+ time = parse_now("5 mornings ago")
799
+ assert_equal Time.local(2006, 8, 12, 9), time
800
+
801
+ time = parse_now("7 hours ago")
802
+ assert_equal Time.local(2006, 8, 16, 7), time
803
+
804
+ time = parse_now("3 minutes ago")
805
+ assert_equal Time.local(2006, 8, 16, 13, 57), time
806
+
807
+ time = parse_now("20 seconds before now")
808
+ assert_equal Time.local(2006, 8, 16, 13, 59, 40), time
809
+
810
+ # future
811
+
812
+ time = parse_now("3 years from now")
813
+ assert_equal Time.local(2009, 8, 16, 14, 0, 0), time
814
+
815
+ time = parse_now("6 months hence")
816
+ assert_equal Time.local(2007, 2, 16, 14), time
817
+
818
+ time = parse_now("3 fortnights hence")
819
+ assert_equal Time.local(2006, 9, 27, 14), time
820
+
821
+ time = parse_now("1 week from now")
822
+ assert_equal Time.local(2006, 8, 23, 14, 0, 0), time
823
+
824
+ time = parse_now("1 weekend from now")
825
+ assert_equal Time.local(2006, 8, 19), time
826
+
827
+ time = parse_now("2 weekends from now")
828
+ assert_equal Time.local(2006, 8, 26), time
829
+
830
+ time = parse_now("1 day hence")
831
+ assert_equal Time.local(2006, 8, 17, 14), time
832
+
833
+ time = parse_now("5 mornings hence")
834
+ assert_equal Time.local(2006, 8, 21, 9), time
835
+
836
+ time = parse_now("1 hour from now")
837
+ assert_equal Time.local(2006, 8, 16, 15), time
838
+
839
+ time = parse_now("20 minutes hence")
840
+ assert_equal Time.local(2006, 8, 16, 14, 20), time
841
+
842
+ time = parse_now("20 seconds from now")
843
+ assert_equal Time.local(2006, 8, 16, 14, 0, 20), time
844
+
845
+ time = Chronic.parse("2 months ago", :now => Time.parse("2007-03-07 23:30"))
846
+ assert_equal Time.local(2007, 1, 7, 23, 30), time
847
+ end
848
+
849
+ def test_parse_guess_p_s_r
850
+ time = parse_now("in 3 hours")
851
+ assert_equal Time.local(2006, 8, 16, 17), time
852
+ end
853
+
854
+ def test_parse_guess_s_r_p_a
855
+ # past
856
+
857
+ time = parse_now("3 years ago tomorrow")
858
+ assert_equal Time.local(2003, 8, 17, 12), time
859
+
860
+ time = parse_now("3 years ago this friday")
861
+ assert_equal Time.local(2003, 8, 18, 12), time
862
+
863
+ time = parse_now("3 months ago saturday at 5:00 pm")
864
+ assert_equal Time.local(2006, 5, 19, 17), time
865
+
866
+ time = parse_now("2 days from this second")
867
+ assert_equal Time.local(2006, 8, 18, 14), time
868
+
869
+ time = parse_now("7 hours before tomorrow at midnight")
870
+ assert_equal Time.local(2006, 8, 17, 17), time
871
+
872
+ # future
873
+ end
874
+
875
+ def test_parse_guess_o_r_g_r
876
+ time = parse_now("3rd month next year", :guess => false)
877
+ assert_equal Time.local(2007, 3), time.begin
878
+
879
+ time = parse_now("3rd month next year", :guess => false)
880
+ assert_equal Time.local(2007, 3, 1), time.begin
881
+
882
+ time = parse_now("3rd thursday this september")
883
+ assert_equal Time.local(2006, 9, 21, 12), time
884
+
885
+ now = Time.parse("1/10/2010")
886
+ time = parse_now("3rd thursday this november", :now => now)
887
+ assert_equal Time.local(2010, 11, 18, 12), time
888
+
889
+ time = parse_now("4th day last week")
890
+ assert_equal Time.local(2006, 8, 9, 12), time
891
+ end
892
+
893
+ def test_parse_guess_nonsense
894
+ time = parse_now("some stupid nonsense")
895
+ assert_equal nil, time
896
+
897
+ time = parse_now("Ham Sandwich")
898
+ assert_equal nil, time
899
+ end
900
+
901
+ def test_parse_span
902
+ span = parse_now("friday", :guess => false)
903
+ assert_equal Time.local(2006, 8, 18), span.begin
904
+ assert_equal Time.local(2006, 8, 19), span.end
905
+
906
+ span = parse_now("november", :guess => false)
907
+ assert_equal Time.local(2006, 11), span.begin
908
+ assert_equal Time.local(2006, 12), span.end
909
+
910
+ span = Chronic.parse("weekend" , :now => @time_2006_08_16_14_00_00, :guess => false)
911
+ assert_equal Time.local(2006, 8, 19), span.begin
912
+ assert_equal Time.local(2006, 8, 21), span.end
913
+ end
914
+
915
+ def test_parse_with_endian_precedence
916
+ date = '11/02/2007'
917
+
918
+ expect_for_middle_endian = Time.local(2007, 11, 2, 12)
919
+ expect_for_little_endian = Time.local(2007, 2, 11, 12)
920
+
921
+ # default precedence should be toward middle endianness
922
+ assert_equal expect_for_middle_endian, Chronic.parse(date)
923
+
924
+ assert_equal expect_for_middle_endian, Chronic.parse(date, :endian_precedence => [:middle, :little])
925
+
926
+ assert_equal expect_for_little_endian, Chronic.parse(date, :endian_precedence => [:little, :middle])
927
+ end
928
+
929
+ def test_parse_words
930
+ assert_equal parse_now("33 days from now"), parse_now("thirty-three days from now")
931
+ assert_equal parse_now("2867532 seconds from now"), parse_now("two million eight hundred and sixty seven thousand five hundred and thirty two seconds from now")
932
+ assert_equal parse_now("may 10th"), parse_now("may tenth")
933
+ assert_equal parse_now("second monday in january"), parse_now("2nd monday in january")
934
+ end
935
+
936
+ def test_parse_only_complete_pointers
937
+ assert_equal parse_now("eat pasty buns today at 2pm"), @time_2006_08_16_14_00_00
938
+ assert_equal parse_now("futuristically speaking today at 2pm"), @time_2006_08_16_14_00_00
939
+ assert_equal parse_now("meeting today at 2pm"), @time_2006_08_16_14_00_00
940
+ end
941
+
942
+ def test_am_pm
943
+ assert_equal Time.local(2006, 8, 16), parse_now("8/16/2006 at 12am")
944
+ assert_equal Time.local(2006, 8, 16, 12), parse_now("8/16/2006 at 12pm")
945
+ end
946
+
947
+ def test_a_p
948
+ assert_equal Time.local(2006, 8, 16, 0, 15), parse_now("8/16/2006 at 12:15a")
949
+ assert_equal Time.local(2006, 8, 16, 18, 30), parse_now("8/16/2006 at 6:30p")
950
+ end
951
+
952
+ def test_argument_validation
953
+ assert_raises(ArgumentError) do
954
+ time = Chronic.parse("may 27", :foo => :bar)
955
+ end
956
+
957
+ assert_raises(ArgumentError) do
958
+ time = Chronic.parse("may 27", :context => :bar)
959
+ end
960
+ end
961
+
962
+ def test_seasons
963
+ t = parse_now("this spring", :guess => false)
964
+ assert_equal Time.local(2007, 3, 20), t.begin
965
+ assert_equal Time.local(2007, 6, 20), t.end
966
+
967
+ t = parse_now("this winter", :guess => false)
968
+ assert_equal Time.local(2006, 12, 22), t.begin
969
+ assert_equal Time.local(2007, 3, 19), t.end
970
+
971
+ t = parse_now("last spring", :guess => false)
972
+ assert_equal Time.local(2006, 3, 20), t.begin
973
+ assert_equal Time.local(2006, 6, 20), t.end
974
+
975
+ t = parse_now("last winter", :guess => false)
976
+ assert_equal Time.local(2005, 12, 22), t.begin
977
+ assert_equal Time.local(2006, 3, 19), t.end
978
+
979
+ t = parse_now("next spring", :guess => false)
980
+ assert_equal Time.local(2007, 3, 20), t.begin
981
+ assert_equal Time.local(2007, 6, 20), t.end
982
+ end
983
+
984
+ # regression
985
+
986
+ # def test_partial
987
+ # assert_equal '', parse_now("2 hours")
988
+ # end
989
+
990
+ def test_days_in_november
991
+ t1 = Chronic.parse('1st thursday in november', :now => Time.local(2007))
992
+ assert_equal Time.local(2007, 11, 1, 12), t1
993
+
994
+ t1 = Chronic.parse('1st friday in november', :now => Time.local(2007))
995
+ assert_equal Time.local(2007, 11, 2, 12), t1
996
+
997
+ t1 = Chronic.parse('1st saturday in november', :now => Time.local(2007))
998
+ assert_equal Time.local(2007, 11, 3, 12), t1
999
+
1000
+ # t1 = Chronic.parse('1st sunday in november', :now => Time.local(2007))
1001
+ # assert_equal Time.local(2007, 11, 4, 12), t1
1002
+
1003
+ # Chronic.debug = true
1004
+ #
1005
+ # t1 = Chronic.parse('1st monday in november', :now => Time.local(2007))
1006
+ # assert_equal Time.local(2007, 11, 5, 11), t1
1007
+ end
1008
+
1009
+ def test_now_changes
1010
+ t1 = Chronic.parse("now")
1011
+ sleep 0.1
1012
+ t2 = Chronic.parse("now")
1013
+ refute_equal t1, t2
1014
+ end
1015
+
1016
+ def test_noon
1017
+ t1 = Chronic.parse('2011-01-01 at noon', :ambiguous_time_range => :none)
1018
+ assert_equal Time.local(2011, 1, 1, 12, 0), t1
1019
+ end
1020
+
1021
+ def test_handle_rdn_rmn_sd
1022
+ time = parse_now("Thu Aug 10")
1023
+ assert_equal Time.local(2006, 8, 10, 12), time
1024
+
1025
+ time = parse_now("Thursday July 31")
1026
+ assert_equal Time.local(2006, 7, 31, 12), time
1027
+
1028
+ time = parse_now("Thursday December 31")
1029
+ assert_equal Time.local(2006, 12, 31, 12), time
1030
+ end
1031
+
1032
+ def test_handle_rdn_rmn_sd_sy
1033
+ time = parse_now("Thu Aug 10 2006")
1034
+ assert_equal Time.local(2006, 8, 10, 12), time
1035
+
1036
+ time = parse_now("Thursday July 31 2006")
1037
+ assert_equal Time.local(2006, 7, 31, 12), time
1038
+
1039
+ time = parse_now("Thursday December 31 2006")
1040
+ assert_equal Time.local(2006, 12, 31, 12), time
1041
+
1042
+ time = parse_now("Thursday December 30 2006")
1043
+ assert_equal Time.local(2006, 12, 30, 12), time
1044
+ end
1045
+
1046
+ def test_handle_rdn_rmn_od
1047
+ time = parse_now("Thu Aug 10th")
1048
+ assert_equal Time.local(2006, 8, 10, 12), time
1049
+
1050
+ time = parse_now("Thursday July 31st")
1051
+ assert_equal Time.local(2006, 7, 31, 12), time
1052
+
1053
+ time = parse_now("Thursday December 31st")
1054
+ assert_equal Time.local(2006, 12, 31, 12), time
1055
+ end
1056
+
1057
+ private
1058
+ def parse_now(string, options={})
1059
+ Chronic.parse(string, {:now => TIME_2006_08_16_14_00_00 }.merge(options))
1060
+ end
1061
+ end