chronic 0.4.1 → 0.6.5

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.
Files changed (64) hide show
  1. data/.gemtest +0 -0
  2. data/.gitignore +5 -0
  3. data/.yardopts +3 -0
  4. data/HISTORY.md +75 -2
  5. data/README.md +10 -5
  6. data/Rakefile +12 -106
  7. data/chronic.gemspec +12 -78
  8. data/lib/chronic/chronic.rb +271 -101
  9. data/lib/chronic/grabber.rb +12 -3
  10. data/lib/chronic/handler.rb +90 -0
  11. data/lib/chronic/handlers.rb +247 -295
  12. data/lib/chronic/mini_date.rb +15 -5
  13. data/lib/chronic/numerizer.rb +3 -2
  14. data/lib/chronic/ordinal.rb +15 -4
  15. data/lib/chronic/pointer.rb +13 -5
  16. data/lib/chronic/repeater.rb +31 -15
  17. data/lib/chronic/repeaters/repeater_day.rb +6 -7
  18. data/lib/chronic/repeaters/repeater_day_name.rb +1 -2
  19. data/lib/chronic/repeaters/repeater_day_portion.rb +12 -13
  20. data/lib/chronic/repeaters/repeater_fortnight.rb +2 -3
  21. data/lib/chronic/repeaters/repeater_hour.rb +7 -8
  22. data/lib/chronic/repeaters/repeater_minute.rb +6 -7
  23. data/lib/chronic/repeaters/repeater_month.rb +22 -11
  24. data/lib/chronic/repeaters/repeater_month_name.rb +16 -24
  25. data/lib/chronic/repeaters/repeater_season.rb +10 -29
  26. data/lib/chronic/repeaters/repeater_season_name.rb +2 -4
  27. data/lib/chronic/repeaters/repeater_second.rb +0 -1
  28. data/lib/chronic/repeaters/repeater_time.rb +19 -20
  29. data/lib/chronic/repeaters/repeater_week.rb +0 -1
  30. data/lib/chronic/repeaters/repeater_weekday.rb +1 -2
  31. data/lib/chronic/repeaters/repeater_weekend.rb +0 -1
  32. data/lib/chronic/repeaters/repeater_year.rb +29 -18
  33. data/lib/chronic/scalar.rb +29 -1
  34. data/lib/chronic/season.rb +37 -0
  35. data/lib/chronic/separator.rb +24 -7
  36. data/lib/chronic/tag.rb +12 -1
  37. data/lib/chronic/time_zone.rb +14 -5
  38. data/lib/chronic/token.rb +14 -4
  39. data/lib/chronic.rb +66 -89
  40. data/test/helper.rb +1 -1
  41. data/test/test_Chronic.rb +97 -3
  42. data/test/test_DaylightSavings.rb +1 -1
  43. data/test/test_Handler.rb +1 -6
  44. data/test/test_MiniDate.rb +3 -3
  45. data/test/test_Numerizer.rb +1 -1
  46. data/test/test_RepeaterDayName.rb +1 -1
  47. data/test/test_RepeaterFortnight.rb +1 -1
  48. data/test/test_RepeaterHour.rb +1 -1
  49. data/test/test_RepeaterMinute.rb +1 -1
  50. data/test/test_RepeaterMonth.rb +5 -1
  51. data/test/test_RepeaterMonthName.rb +1 -1
  52. data/test/test_RepeaterSeason.rb +40 -0
  53. data/test/test_RepeaterTime.rb +1 -1
  54. data/test/test_RepeaterWeek.rb +1 -1
  55. data/test/test_RepeaterWeekday.rb +1 -1
  56. data/test/test_RepeaterWeekend.rb +1 -1
  57. data/test/test_RepeaterYear.rb +8 -1
  58. data/test/test_Span.rb +1 -1
  59. data/test/test_Token.rb +1 -1
  60. data/test/test_parsing.rb +228 -117
  61. metadata +30 -32
  62. data/Manifest.txt +0 -59
  63. data/benchmark/benchmark.rb +0 -13
  64. data/test/test_Time.rb +0 -49
data/test/test_parsing.rb CHANGED
@@ -1,4 +1,4 @@
1
- require File.join(File.dirname(__FILE__), *%w[helper])
1
+ require 'helper'
2
2
 
3
3
  class TestParsing < Test::Unit::TestCase
4
4
  # Wed Aug 16 14:00:00 UTC 2006
@@ -8,8 +8,18 @@ class TestParsing < Test::Unit::TestCase
8
8
  @time_2006_08_16_14_00_00 = TIME_2006_08_16_14_00_00
9
9
  end
10
10
 
11
- def test_parse_guess_dates
12
- # rm_sd
11
+ def test_handle_rmn_sd
12
+ time = parse_now("aug 3")
13
+ assert_equal Time.local(2006, 8, 3, 12), time
14
+
15
+ time = parse_now("aug 3", :context => :past)
16
+ assert_equal Time.local(2006, 8, 3, 12), time
17
+
18
+ time = parse_now("aug 20")
19
+ assert_equal Time.local(2006, 8, 20, 12), time
20
+
21
+ time = parse_now("aug 20", :context => :future)
22
+ assert_equal Time.local(2006, 8, 20, 12), time
13
23
 
14
24
  time = parse_now("may 27")
15
25
  assert_equal Time.local(2007, 5, 27, 12), time
@@ -25,23 +35,9 @@ class TestParsing < Test::Unit::TestCase
25
35
 
26
36
  time = parse_now("may 28 at 5:32.19pm", :context => :past)
27
37
  assert_equal Time.local(2006, 5, 28, 17, 32, 19), time
38
+ end
28
39
 
29
- # rm_sd for current month
30
-
31
- time = parse_now("aug 3")
32
- assert_equal Time.local(2006, 8, 3, 12), time
33
-
34
- time = parse_now("aug 3", :context => :past)
35
- assert_equal Time.local(2006, 8, 3, 12), time
36
-
37
- time = parse_now("aug 20")
38
- assert_equal Time.local(2006, 8, 20, 12), time
39
-
40
- time = parse_now("aug 20", :context => :future)
41
- assert_equal Time.local(2006, 8, 20, 12), time
42
-
43
- # rm_sd_on
44
-
40
+ def test_handle_rmn_sd_on
45
41
  time = parse_now("5pm on may 28")
46
42
  assert_equal Time.local(2007, 5, 28, 17), time
47
43
 
@@ -50,9 +46,9 @@ class TestParsing < Test::Unit::TestCase
50
46
 
51
47
  time = parse_now("5 on may 28", :ambiguous_time_range => :none)
52
48
  assert_equal Time.local(2007, 5, 28, 05), time
49
+ end
53
50
 
54
- # rm_od
55
-
51
+ def test_handle_rmn_od
56
52
  time = parse_now("may 27th")
57
53
  assert_equal Time.local(2007, 5, 27, 12), time
58
54
 
@@ -67,9 +63,36 @@ class TestParsing < Test::Unit::TestCase
67
63
 
68
64
  time = parse_now("may 27th at 5", :ambiguous_time_range => :none)
69
65
  assert_equal Time.local(2007, 5, 27, 5), time
66
+ end
67
+
68
+ def test_handle_od_rmn
69
+ time = parse_now("22nd February")
70
+ assert_equal Time.local(2007, 2, 22, 12), time
70
71
 
71
- # rm_od_on
72
+ time = parse_now("31st of may at 6:30pm")
73
+ assert_equal Time.local(2007, 5, 31, 18, 30), time
72
74
 
75
+ time = parse_now("11th december 8am")
76
+ assert_equal Time.local(2006, 12, 11, 8), time
77
+ end
78
+
79
+ def test_handle_sy_rmn_od
80
+ time = parse_now("2009 May 22nd")
81
+ assert_equal Time.local(2009, 05, 22, 12), time
82
+ end
83
+
84
+ def test_handle_sd_rmn
85
+ time = parse_now("22 February")
86
+ assert_equal Time.local(2007, 2, 22, 12), time
87
+
88
+ time = parse_now("31 of may at 6:30pm")
89
+ assert_equal Time.local(2007, 5, 31, 18, 30), time
90
+
91
+ time = parse_now("11 december 8am")
92
+ assert_equal Time.local(2006, 12, 11, 8), time
93
+ end
94
+
95
+ def test_handle_rmn_od_on
73
96
  time = parse_now("5:00 pm may 27th", :context => :past)
74
97
  assert_equal Time.local(2006, 5, 27, 17), time
75
98
 
@@ -81,52 +104,42 @@ class TestParsing < Test::Unit::TestCase
81
104
 
82
105
  time = parse_now("5 on may 27th", :ambiguous_time_range => :none)
83
106
  assert_equal Time.local(2007, 5, 27, 5), time
107
+ end
84
108
 
85
- # rm_sy
86
-
87
- time = parse_now("June 1979")
88
- assert_equal Time.local(1979, 6, 16, 0), time
89
-
90
- time = parse_now("dec 79")
91
- assert_equal Time.local(1979, 12, 16, 12), time
92
-
93
- # rm_od_sy
94
-
95
- time = parse_now("November 18th 2010")
96
- assert_equal Time.local(2010, 11, 18, 12), time
97
-
98
- time = parse_now("November 18th, 2010")
99
- assert_equal Time.local(2010, 11, 18, 12), time
100
-
101
- time = parse_now("November 18th 2010 midnight")
102
- assert_equal Time.local(2010, 11, 19, 0), time
103
-
104
- time = parse_now("November 18th 2010 at midnight")
105
- assert_equal Time.local(2010, 11, 19, 0), time
106
-
107
- time = parse_now("November 18th 2010 at 4")
108
- assert_equal Time.local(2010, 11, 18, 16), time
109
+ def test_handle_rmn_sy
110
+ time = parse_now("may 97")
111
+ assert_equal Time.local(1997, 5, 16, 12), time
109
112
 
110
- time = parse_now("November 18th 2010 at 4", :ambiguous_time_range => :none)
111
- assert_equal Time.local(2010, 11, 18, 4), time
113
+ time = parse_now("may 33", :ambiguous_year_future_bias => 10)
114
+ assert_equal Time.local(2033, 5, 16, 12), time
112
115
 
113
- time = parse_now("March 30th, 1979")
114
- assert_equal Time.local(1979, 3, 30, 12), time
116
+ time = parse_now("may 32")
117
+ assert_equal Time.local(2032, 5, 16, 12, 0, 0), time
118
+ end
115
119
 
116
- time = parse_now("March 30th 79")
117
- assert_equal Time.local(1979, 3, 30, 12), time
120
+ def test_handle_rdn_rmn_sd_t_tz_sy
121
+ time = parse_now("Mon Apr 02 17:00:00 PDT 2007")
122
+ assert_equal 1175558400, time.to_i
123
+ end
118
124
 
119
- time = parse_now("March 30th 79 4:30")
120
- assert_equal Time.local(1979, 3, 30, 16, 30), time
125
+ def test_handle_sy_sm_sd_t_tz
126
+ time = parse_now("2011-07-03 22:11:35 +0100")
127
+ assert_equal 1309727495, time.to_i
121
128
 
122
- time = parse_now("March 30th 79 at 4:30", :ambiguous_time_range => :none)
123
- assert_equal Time.local(1979, 3, 30, 4, 30), time
129
+ time = parse_now("2011-07-03 22:11:35 +01:00")
130
+ assert_equal 1309727495, time.to_i
124
131
 
125
- # rm_sd_sy
132
+ time = parse_now("2011-07-03 21:11:35 UTC")
133
+ assert_equal 1309727495, time.to_i
134
+ end
126
135
 
136
+ def test_handle_rmn_sd_sy
127
137
  time = parse_now("November 18, 2010")
128
138
  assert_equal Time.local(2010, 11, 18, 12), time
129
139
 
140
+ time = parse_now("Jan 1,2010")
141
+ assert_equal Time.local(2010, 1, 1, 12), time
142
+
130
143
  time = parse_now("February 14, 2004")
131
144
  assert_equal Time.local(2004, 2, 14, 12), time
132
145
 
@@ -142,9 +155,6 @@ class TestParsing < Test::Unit::TestCase
142
155
  time = parse_now("jan 3 2010 at 4", :ambiguous_time_range => :none)
143
156
  assert_equal Time.local(2010, 1, 3, 4), time
144
157
 
145
- #time = parse_now("January 12, '00")
146
- #assert_equal Time.local(2000, 1, 12, 12), time
147
-
148
158
  time = parse_now("may 27, 1979")
149
159
  assert_equal Time.local(1979, 5, 27, 12), time
150
160
 
@@ -157,8 +167,54 @@ class TestParsing < Test::Unit::TestCase
157
167
  time = parse_now("may 27 79 at 4:30", :ambiguous_time_range => :none)
158
168
  assert_equal Time.local(1979, 5, 27, 4, 30), time
159
169
 
160
- # sd_rm_sy
170
+ time = parse_now("may 27 32")
171
+ assert_equal Time.local(2032, 5, 27, 12, 0, 0), time
172
+ end
173
+
174
+ def test_handle_rmn_od_sy
175
+ time = parse_now("may 1st 01")
176
+ assert_equal Time.local(2001, 5, 1, 12), time
177
+
178
+ time = parse_now("November 18th 2010")
179
+ assert_equal Time.local(2010, 11, 18, 12), time
180
+
181
+ time = parse_now("November 18th, 2010")
182
+ assert_equal Time.local(2010, 11, 18, 12), time
183
+
184
+ time = parse_now("November 18th 2010 midnight")
185
+ assert_equal Time.local(2010, 11, 19, 0), time
186
+
187
+ time = parse_now("November 18th 2010 at midnight")
188
+ assert_equal Time.local(2010, 11, 19, 0), time
189
+
190
+ time = parse_now("November 18th 2010 at 4")
191
+ assert_equal Time.local(2010, 11, 18, 16), time
192
+
193
+ time = parse_now("November 18th 2010 at 4", :ambiguous_time_range => :none)
194
+ assert_equal Time.local(2010, 11, 18, 4), time
195
+
196
+ time = parse_now("March 30th, 1979")
197
+ assert_equal Time.local(1979, 3, 30, 12), time
161
198
 
199
+ time = parse_now("March 30th 79")
200
+ assert_equal Time.local(1979, 3, 30, 12), time
201
+
202
+ time = parse_now("March 30th 79 4:30")
203
+ assert_equal Time.local(1979, 3, 30, 16, 30), time
204
+
205
+ time = parse_now("March 30th 79 at 4:30", :ambiguous_time_range => :none)
206
+ assert_equal Time.local(1979, 3, 30, 4, 30), time
207
+ end
208
+
209
+ def test_handle_od_rmn_sy
210
+ time = parse_now("22nd February 2012")
211
+ assert_equal Time.local(2012, 2, 22, 12), time
212
+
213
+ time = parse_now("11th december 79")
214
+ assert_equal Time.local(1979, 12, 11, 12), time
215
+ end
216
+
217
+ def test_handle_sd_rmn_sy
162
218
  time = parse_now("3 jan 2010")
163
219
  assert_equal Time.local(2010, 1, 3, 12), time
164
220
 
@@ -167,36 +223,38 @@ class TestParsing < Test::Unit::TestCase
167
223
 
168
224
  time = parse_now("27 Oct 2006 7:30pm")
169
225
  assert_equal Time.local(2006, 10, 27, 19, 30), time
226
+ end
170
227
 
171
- # sm_sd_sy
172
-
228
+ def test_handle_sm_sd_sy
173
229
  time = parse_now("5/27/1979")
174
230
  assert_equal Time.local(1979, 5, 27, 12), time
175
231
 
176
232
  time = parse_now("5/27/1979 4am")
177
233
  assert_equal Time.local(1979, 5, 27, 4), time
178
234
 
179
- # sd_sm_sy
235
+ time = parse_now("7/12/11")
236
+ assert_equal Time.local(2011, 7, 12, 12), time
237
+
238
+ time = parse_now("7/12/11", :endian_precedence => :little)
239
+ assert_equal Time.local(2011, 12, 7, 12), time
240
+
241
+ time = parse_now("9/19/2011 6:05:57 PM")
242
+ assert_equal Time.local(2011, 9, 19, 18, 05, 57), time
243
+
244
+ # month day overflows
245
+ time = parse_now("30/2/2000")
246
+ assert_nil time
247
+ end
180
248
 
249
+ def test_handle_sd_sm_sy
181
250
  time = parse_now("27/5/1979")
182
251
  assert_equal Time.local(1979, 5, 27, 12), time
183
252
 
184
253
  time = parse_now("27/5/1979 @ 0700")
185
254
  assert_equal Time.local(1979, 5, 27, 7), time
255
+ end
186
256
 
187
- # sm_sy
188
-
189
- time = parse_now("05/06")
190
- assert_equal Time.local(2006, 5, 16, 12), time
191
-
192
- time = parse_now("12/06")
193
- assert_equal Time.local(2006, 12, 16, 12), time
194
-
195
- time = parse_now("13/06")
196
- assert_equal nil, time
197
-
198
- # sy_sm_sd
199
-
257
+ def test_handle_sy_sm_sd
200
258
  time = parse_now("2000-1-1")
201
259
  assert_equal Time.local(2000, 1, 1, 12), time
202
260
 
@@ -218,43 +276,86 @@ class TestParsing < Test::Unit::TestCase
218
276
  time = parse_now("2006-08-20 15:30.30")
219
277
  assert_equal Time.local(2006, 8, 20, 15, 30, 30), time
220
278
 
221
- # rdn_rm_rd_rt_rtz_ry
279
+ time = parse_now("1902-08-20")
280
+ assert_equal Time.local(1902, 8, 20, 12, 0, 0), time
281
+ end
222
282
 
223
- time = parse_now("Mon Apr 02 17:00:00 PDT 2007")
224
- assert_equal 1175558400, time.to_i
283
+ def test_handle_sm_sy
284
+ time = parse_now("05/06")
285
+ assert_equal Time.local(2006, 5, 16, 12), time
225
286
 
226
- now = Time.now
227
- time = parse_now(now.to_s)
228
- # assert_equal now.to_s, time.to_s
287
+ time = parse_now("12/06")
288
+ assert_equal Time.local(2006, 12, 16, 12), time
229
289
 
230
- # rm_sd_rt
290
+ time = parse_now("13/06")
291
+ assert_equal nil, time
292
+ end
231
293
 
232
- #time = parse_now("jan 5 13:00")
233
- #assert_equal Time.local(2007, 1, 5, 13), time
294
+ def test_handle_r
295
+ end
234
296
 
235
- # old dates
297
+ def test_handle_r_g_r
298
+ end
236
299
 
237
- time = parse_now("may 40")
238
- assert_equal Time.local(2040, 5, 16, 12, 0, 0), time
300
+ def test_handle_srp
301
+ end
239
302
 
240
- time = parse_now("may 27 40")
241
- assert_equal Time.local(2040, 5, 27, 12, 0, 0), time
303
+ def test_handle_s_r_p
304
+ end
242
305
 
243
- time = parse_now("1800-08-20")
244
- assert_equal Time.local(1800, 8, 20, 12, 0, 0), time
306
+ def test_handle_p_s_r
245
307
  end
246
308
 
247
- def test_parse_two_digit_years
248
- time = parse_now("may 97")
249
- assert_equal Time.local(1997, 5, 16, 12), time
309
+ def test_handle_s_r_p_a
310
+ end
250
311
 
251
- time = parse_now("may 1st 01")
252
- assert_equal Time.local(2001, 5, 1, 12), time
312
+ def test_handle_orr
313
+ time = parse_now("5th tuesday in january")
314
+ assert_equal Time.local(2007, 01, 30, 12), time
253
315
 
254
- time = parse_now("may 79", :ambiguous_year_future_bias => 10)
255
- assert_equal Time.local(2079, 5, 16, 12), time
316
+ time = parse_now("5th tuesday in february")
317
+ assert_equal nil, time
318
+
319
+ %W(jan feb march april may june july aug sep oct nov dec).each_with_index do |month, index|
320
+ time = parse_now("5th tuesday in #{month}")
321
+
322
+ if time then
323
+ assert_equal time.month, index+1
324
+ end
325
+ end
326
+ end
327
+
328
+ def test_handle_o_r_s_r
329
+ time = parse_now("3rd wednesday in november")
330
+ assert_equal Time.local(2006, 11, 15, 12), time
331
+
332
+ time = parse_now("10th wednesday in november")
333
+ assert_equal nil, time
334
+
335
+ # time = parse_now("3rd wednesday in 2007")
336
+ # assert_equal Time.local(2007, 1, 20, 12), time
337
+ end
338
+
339
+ def test_handle_o_r_g_r
340
+ time = parse_now("3rd month next year", :guess => false)
341
+ assert_equal Time.local(2007, 3), time.begin
342
+
343
+ time = parse_now("3rd month next year", :guess => false)
344
+ assert_equal Time.local(2007, 3, 1), time.begin
345
+
346
+ time = parse_now("3rd thursday this september")
347
+ assert_equal Time.local(2006, 9, 21, 12), time
348
+
349
+ now = Time.parse("1/10/2010")
350
+ time = parse_now("3rd thursday this november", :now => now)
351
+ assert_equal Time.local(2010, 11, 18, 12), time
352
+
353
+ time = parse_now("4th day last week")
354
+ assert_equal Time.local(2006, 8, 9, 12), time
256
355
  end
257
356
 
357
+ # end of testing handlers
358
+
258
359
  def test_parse_guess_r
259
360
  time = parse_now("friday")
260
361
  assert_equal Time.local(2006, 8, 18, 12), time
@@ -274,6 +375,12 @@ class TestParsing < Test::Unit::TestCase
274
375
  time = parse_now("13:45")
275
376
  assert_equal Time.local(2006, 8, 17, 13, 45), time
276
377
 
378
+ time = parse_now("1:01pm")
379
+ assert_equal Time.local(2006, 8, 16, 13, 01), time
380
+
381
+ time = parse_now("2:01pm")
382
+ assert_equal Time.local(2006, 8, 16, 14, 01), time
383
+
277
384
  time = parse_now("november")
278
385
  assert_equal Time.local(2006, 11, 16), time
279
386
  end
@@ -342,11 +449,11 @@ class TestParsing < Test::Unit::TestCase
342
449
  def test_parse_guess_gr
343
450
  # year
344
451
 
345
- time = parse_now("this year")
346
- assert_equal Time.local(2006, 10, 24, 12, 30), time
452
+ time = parse_now("this year", :guess => false)
453
+ assert_equal Time.local(2006, 8, 17), time.begin
347
454
 
348
- time = parse_now("this year", :context => :past)
349
- assert_equal Time.local(2006, 4, 24, 12, 30), time
455
+ time = parse_now("this year", :context => :past, :guess => false)
456
+ assert_equal Time.local(2006, 1, 1), time.begin
350
457
 
351
458
  # month
352
459
 
@@ -643,17 +750,6 @@ class TestParsing < Test::Unit::TestCase
643
750
  # future
644
751
  end
645
752
 
646
- def test_parse_guess_o_r_s_r
647
- time = parse_now("3rd wednesday in november")
648
- assert_equal Time.local(2006, 11, 15, 12), time
649
-
650
- time = parse_now("10th wednesday in november")
651
- assert_equal nil, time
652
-
653
- # time = parse_now("3rd wednesday in 2007")
654
- # assert_equal Time.local(2007, 1, 20, 12), time
655
- end
656
-
657
753
  def test_parse_guess_o_r_g_r
658
754
  time = parse_now("3rd month next year", :guess => false)
659
755
  assert_equal Time.local(2007, 3), time.begin
@@ -731,11 +827,11 @@ class TestParsing < Test::Unit::TestCase
731
827
  end
732
828
 
733
829
  def test_argument_validation
734
- assert_raise(Chronic::InvalidArgumentException) do
830
+ assert_raise(ArgumentError) do
735
831
  time = Chronic.parse("may 27", :foo => :bar)
736
832
  end
737
833
 
738
- assert_raise(Chronic::InvalidArgumentException) do
834
+ assert_raise(ArgumentError) do
739
835
  time = Chronic.parse("may 27", :context => :bar)
740
836
  end
741
837
  end
@@ -794,6 +890,21 @@ class TestParsing < Test::Unit::TestCase
794
890
  assert_not_equal t1, t2
795
891
  end
796
892
 
893
+ def test_noon
894
+ t1 = Chronic.parse('2011-01-01 at noon', :ambiguous_time_range => :none)
895
+ assert_equal Time.local(2011, 1, 1, 12, 0), t1
896
+ end
897
+
898
+ def test_handle_rdn_rmn_sd
899
+ time = parse_now("Thu Aug 10")
900
+ assert_equal Time.local(2006, 8, 10, 12), time
901
+ end
902
+
903
+ def test_handle_rdn_rmn_od
904
+ time = parse_now("Thu Aug 10th")
905
+ assert_equal Time.local(2006, 8, 10, 12), time
906
+ end
907
+
797
908
  private
798
909
  def parse_now(string, options={})
799
910
  Chronic.parse(string, {:now => TIME_2006_08_16_14_00_00 }.merge(options))
metadata CHANGED
@@ -1,42 +1,40 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: chronic
3
- version: !ruby/object:Gem::Version
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.6.5
4
5
  prerelease:
5
- version: 0.4.1
6
6
  platform: ruby
7
- authors:
7
+ authors:
8
8
  - Tom Preston-Werner
9
9
  - Lee Jarvis
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
-
14
- date: 2011-06-05 00:00:00 Z
13
+ date: 2011-11-05 00:00:00.000000000Z
15
14
  dependencies: []
16
-
17
15
  description: Chronic is a natural language date/time parser written in pure Ruby.
18
- email:
16
+ email:
19
17
  - tom@mojombo.com
20
18
  - lee@jarvis.co
21
19
  executables: []
22
-
23
20
  extensions: []
24
-
25
- extra_rdoc_files:
21
+ extra_rdoc_files:
26
22
  - README.md
27
23
  - HISTORY.md
28
24
  - LICENSE
29
- files:
25
+ files:
26
+ - .gemtest
27
+ - .gitignore
28
+ - .yardopts
30
29
  - HISTORY.md
31
30
  - LICENSE
32
- - Manifest.txt
33
31
  - README.md
34
32
  - Rakefile
35
- - benchmark/benchmark.rb
36
33
  - chronic.gemspec
37
34
  - lib/chronic.rb
38
35
  - lib/chronic/chronic.rb
39
36
  - lib/chronic/grabber.rb
37
+ - lib/chronic/handler.rb
40
38
  - lib/chronic/handlers.rb
41
39
  - lib/chronic/mini_date.rb
42
40
  - lib/chronic/numerizer.rb
@@ -60,6 +58,7 @@ files:
60
58
  - lib/chronic/repeaters/repeater_weekend.rb
61
59
  - lib/chronic/repeaters/repeater_year.rb
62
60
  - lib/chronic/scalar.rb
61
+ - lib/chronic/season.rb
63
62
  - lib/chronic/separator.rb
64
63
  - lib/chronic/span.rb
65
64
  - lib/chronic/tag.rb
@@ -77,43 +76,42 @@ files:
77
76
  - test/test_RepeaterMinute.rb
78
77
  - test/test_RepeaterMonth.rb
79
78
  - test/test_RepeaterMonthName.rb
79
+ - test/test_RepeaterSeason.rb
80
80
  - test/test_RepeaterTime.rb
81
81
  - test/test_RepeaterWeek.rb
82
82
  - test/test_RepeaterWeekday.rb
83
83
  - test/test_RepeaterWeekend.rb
84
84
  - test/test_RepeaterYear.rb
85
85
  - test/test_Span.rb
86
- - test/test_Time.rb
87
86
  - test/test_Token.rb
88
87
  - test/test_parsing.rb
89
88
  homepage: http://github.com/mojombo/chronic
90
89
  licenses: []
91
-
92
90
  post_install_message:
93
- rdoc_options:
91
+ rdoc_options:
94
92
  - --charset=UTF-8
95
- require_paths:
93
+ require_paths:
96
94
  - lib
97
- required_ruby_version: !ruby/object:Gem::Requirement
95
+ required_ruby_version: !ruby/object:Gem::Requirement
98
96
  none: false
99
- requirements:
100
- - - ">="
101
- - !ruby/object:Gem::Version
102
- version: "0"
103
- required_rubygems_version: !ruby/object:Gem::Requirement
97
+ requirements:
98
+ - - ! '>='
99
+ - !ruby/object:Gem::Version
100
+ version: '0'
101
+ required_rubygems_version: !ruby/object:Gem::Requirement
104
102
  none: false
105
- requirements:
106
- - - ">="
107
- - !ruby/object:Gem::Version
108
- version: "0"
103
+ requirements:
104
+ - - ! '>='
105
+ - !ruby/object:Gem::Version
106
+ version: '0'
109
107
  requirements: []
110
-
111
108
  rubyforge_project: chronic
112
- rubygems_version: 1.8.2
109
+ rubygems_version: 1.8.11
113
110
  signing_key:
114
111
  specification_version: 3
115
112
  summary: Natural language date/time parsing.
116
- test_files:
113
+ test_files:
114
+ - test/helper.rb
117
115
  - test/test_Chronic.rb
118
116
  - test/test_DaylightSavings.rb
119
117
  - test/test_Handler.rb
@@ -125,12 +123,12 @@ test_files:
125
123
  - test/test_RepeaterMinute.rb
126
124
  - test/test_RepeaterMonth.rb
127
125
  - test/test_RepeaterMonthName.rb
126
+ - test/test_RepeaterSeason.rb
128
127
  - test/test_RepeaterTime.rb
129
128
  - test/test_RepeaterWeek.rb
130
129
  - test/test_RepeaterWeekday.rb
131
130
  - test/test_RepeaterWeekend.rb
132
131
  - test/test_RepeaterYear.rb
133
132
  - test/test_Span.rb
134
- - test/test_Time.rb
135
133
  - test/test_Token.rb
136
134
  - test/test_parsing.rb
data/Manifest.txt DELETED
@@ -1,59 +0,0 @@
1
- HISTORY.md
2
- LICENSE
3
- Manifest.txt
4
- README.md
5
- Rakefile
6
- benchmark/benchmark.rb
7
- chronic.gemspec
8
- lib/chronic.rb
9
- lib/chronic/chronic.rb
10
- lib/chronic/grabber.rb
11
- lib/chronic/handlers.rb
12
- lib/chronic/mini_date.rb
13
- lib/chronic/numerizer.rb
14
- lib/chronic/ordinal.rb
15
- lib/chronic/pointer.rb
16
- lib/chronic/repeater.rb
17
- lib/chronic/repeaters/repeater_day.rb
18
- lib/chronic/repeaters/repeater_day_name.rb
19
- lib/chronic/repeaters/repeater_day_portion.rb
20
- lib/chronic/repeaters/repeater_fortnight.rb
21
- lib/chronic/repeaters/repeater_hour.rb
22
- lib/chronic/repeaters/repeater_minute.rb
23
- lib/chronic/repeaters/repeater_month.rb
24
- lib/chronic/repeaters/repeater_month_name.rb
25
- lib/chronic/repeaters/repeater_season.rb
26
- lib/chronic/repeaters/repeater_season_name.rb
27
- lib/chronic/repeaters/repeater_second.rb
28
- lib/chronic/repeaters/repeater_time.rb
29
- lib/chronic/repeaters/repeater_week.rb
30
- lib/chronic/repeaters/repeater_weekday.rb
31
- lib/chronic/repeaters/repeater_weekend.rb
32
- lib/chronic/repeaters/repeater_year.rb
33
- lib/chronic/scalar.rb
34
- lib/chronic/separator.rb
35
- lib/chronic/span.rb
36
- lib/chronic/tag.rb
37
- lib/chronic/time_zone.rb
38
- lib/chronic/token.rb
39
- test/helper.rb
40
- test/test_Chronic.rb
41
- test/test_DaylightSavings.rb
42
- test/test_Handler.rb
43
- test/test_MiniDate.rb
44
- test/test_Numerizer.rb
45
- test/test_RepeaterDayName.rb
46
- test/test_RepeaterFortnight.rb
47
- test/test_RepeaterHour.rb
48
- test/test_RepeaterMinute.rb
49
- test/test_RepeaterMonth.rb
50
- test/test_RepeaterMonthName.rb
51
- test/test_RepeaterTime.rb
52
- test/test_RepeaterWeek.rb
53
- test/test_RepeaterWeekday.rb
54
- test/test_RepeaterWeekend.rb
55
- test/test_RepeaterYear.rb
56
- test/test_Span.rb
57
- test/test_Time.rb
58
- test/test_Token.rb
59
- test/test_parsing.rb
@@ -1,13 +0,0 @@
1
- require 'chronic'
2
- require 'benchmark'
3
-
4
- print "jan 3 2010: "
5
- puts Benchmark.measure { Chronic.parse("jan 3 2010") }
6
-
7
- print "7 hours before tomorrow at midnight: "
8
- puts Benchmark.measure { Chronic.parse("7 hours before tomorrow at midnight") }
9
-
10
- # n = 100
11
- # Benchmark.bm(14) do |x|
12
- # x.report("jan 3 2010:") { for i in 1..n; Chronic.parse("jan 3 2010"); end }
13
- # end