chronic 0.4.1 → 0.6.0

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 (63) hide show
  1. data/.gemtest +0 -0
  2. data/.gitignore +5 -0
  3. data/.yardopts +3 -0
  4. data/HISTORY.md +49 -2
  5. data/README.md +8 -2
  6. data/Rakefile +9 -101
  7. data/chronic.gemspec +12 -78
  8. data/lib/chronic/chronic.rb +260 -101
  9. data/lib/chronic/grabber.rb +12 -3
  10. data/lib/chronic/handler.rb +90 -0
  11. data/lib/chronic/handlers.rb +189 -301
  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 +8 -9
  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 +1 -2
  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 +12 -3
  38. data/lib/chronic/token.rb +14 -4
  39. data/lib/chronic.rb +66 -89
  40. data/test/test_Chronic.rb +97 -3
  41. data/test/test_DaylightSavings.rb +1 -1
  42. data/test/test_Handler.rb +1 -6
  43. data/test/test_MiniDate.rb +3 -3
  44. data/test/test_Numerizer.rb +1 -1
  45. data/test/test_RepeaterDayName.rb +1 -1
  46. data/test/test_RepeaterFortnight.rb +1 -1
  47. data/test/test_RepeaterHour.rb +1 -1
  48. data/test/test_RepeaterMinute.rb +1 -1
  49. data/test/test_RepeaterMonth.rb +5 -1
  50. data/test/test_RepeaterMonthName.rb +1 -1
  51. data/test/test_RepeaterSeason.rb +40 -0
  52. data/test/test_RepeaterTime.rb +1 -1
  53. data/test/test_RepeaterWeek.rb +1 -1
  54. data/test/test_RepeaterWeekday.rb +1 -1
  55. data/test/test_RepeaterWeekend.rb +1 -1
  56. data/test/test_RepeaterYear.rb +8 -1
  57. data/test/test_Span.rb +1 -1
  58. data/test/test_Token.rb +1 -1
  59. data/test/test_parsing.rb +167 -115
  60. metadata +32 -32
  61. data/Manifest.txt +0 -59
  62. data/benchmark/benchmark.rb +0 -13
  63. 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,20 @@ 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
70
67
 
71
- # rm_od_on
68
+ def test_handle_od_rmn
69
+ time = parse_now("22nd February")
70
+ assert_equal Time.local(2007, 2, 22, 12), time
72
71
 
72
+ time = parse_now("31st of may at 6:30pm")
73
+ assert_equal Time.local(2007, 5, 31, 18, 30), time
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_rmn_od_on
73
80
  time = parse_now("5:00 pm may 27th", :context => :past)
74
81
  assert_equal Time.local(2006, 5, 27, 17), time
75
82
 
@@ -81,52 +88,36 @@ class TestParsing < Test::Unit::TestCase
81
88
 
82
89
  time = parse_now("5 on may 27th", :ambiguous_time_range => :none)
83
90
  assert_equal Time.local(2007, 5, 27, 5), time
91
+ end
84
92
 
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
-
110
- time = parse_now("November 18th 2010 at 4", :ambiguous_time_range => :none)
111
- assert_equal Time.local(2010, 11, 18, 4), time
112
-
113
- time = parse_now("March 30th, 1979")
114
- assert_equal Time.local(1979, 3, 30, 12), time
93
+ def test_handle_rmn_sy
94
+ time = parse_now("may 97")
95
+ assert_equal Time.local(1997, 5, 16, 12), time
115
96
 
116
- time = parse_now("March 30th 79")
117
- assert_equal Time.local(1979, 3, 30, 12), time
97
+ time = parse_now("may 33", :ambiguous_year_future_bias => 10)
98
+ assert_equal Time.local(2033, 5, 16, 12), time
118
99
 
119
- time = parse_now("March 30th 79 4:30")
120
- assert_equal Time.local(1979, 3, 30, 16, 30), time
100
+ time = parse_now("may 32")
101
+ assert_equal Time.local(2032, 5, 16, 12, 0, 0), time
102
+ end
121
103
 
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
104
+ def test_handle_rdn_rmn_sd_t_tz_sy
105
+ time = parse_now("Mon Apr 02 17:00:00 PDT 2007")
106
+ assert_equal 1175558400, time.to_i
107
+ end
124
108
 
125
- # rm_sd_sy
109
+ def test_handle_sy_sm_sd_t_tz
110
+ time = parse_now("2011-07-03 22:11:35 +0100")
111
+ assert_equal 1309727495, time.to_i
112
+ end
126
113
 
114
+ def test_handle_rmn_sd_sy
127
115
  time = parse_now("November 18, 2010")
128
116
  assert_equal Time.local(2010, 11, 18, 12), time
129
117
 
118
+ time = parse_now("Jan 1,2010")
119
+ assert_equal Time.local(2010, 1, 1, 12), time
120
+
130
121
  time = parse_now("February 14, 2004")
131
122
  assert_equal Time.local(2004, 2, 14, 12), time
132
123
 
@@ -142,9 +133,6 @@ class TestParsing < Test::Unit::TestCase
142
133
  time = parse_now("jan 3 2010 at 4", :ambiguous_time_range => :none)
143
134
  assert_equal Time.local(2010, 1, 3, 4), time
144
135
 
145
- #time = parse_now("January 12, '00")
146
- #assert_equal Time.local(2000, 1, 12, 12), time
147
-
148
136
  time = parse_now("may 27, 1979")
149
137
  assert_equal Time.local(1979, 5, 27, 12), time
150
138
 
@@ -157,8 +145,54 @@ class TestParsing < Test::Unit::TestCase
157
145
  time = parse_now("may 27 79 at 4:30", :ambiguous_time_range => :none)
158
146
  assert_equal Time.local(1979, 5, 27, 4, 30), time
159
147
 
160
- # sd_rm_sy
148
+ time = parse_now("may 27 32")
149
+ assert_equal Time.local(2032, 5, 27, 12, 0, 0), time
150
+ end
151
+
152
+ def test_handle_rmn_od_sy
153
+ time = parse_now("may 1st 01")
154
+ assert_equal Time.local(2001, 5, 1, 12), time
155
+
156
+ time = parse_now("November 18th 2010")
157
+ assert_equal Time.local(2010, 11, 18, 12), time
161
158
 
159
+ time = parse_now("November 18th, 2010")
160
+ assert_equal Time.local(2010, 11, 18, 12), time
161
+
162
+ time = parse_now("November 18th 2010 midnight")
163
+ assert_equal Time.local(2010, 11, 19, 0), time
164
+
165
+ time = parse_now("November 18th 2010 at midnight")
166
+ assert_equal Time.local(2010, 11, 19, 0), time
167
+
168
+ time = parse_now("November 18th 2010 at 4")
169
+ assert_equal Time.local(2010, 11, 18, 16), time
170
+
171
+ time = parse_now("November 18th 2010 at 4", :ambiguous_time_range => :none)
172
+ assert_equal Time.local(2010, 11, 18, 4), time
173
+
174
+ time = parse_now("March 30th, 1979")
175
+ assert_equal Time.local(1979, 3, 30, 12), time
176
+
177
+ time = parse_now("March 30th 79")
178
+ assert_equal Time.local(1979, 3, 30, 12), time
179
+
180
+ time = parse_now("March 30th 79 4:30")
181
+ assert_equal Time.local(1979, 3, 30, 16, 30), time
182
+
183
+ time = parse_now("March 30th 79 at 4:30", :ambiguous_time_range => :none)
184
+ assert_equal Time.local(1979, 3, 30, 4, 30), time
185
+ end
186
+
187
+ def test_handle_od_rmn_sy
188
+ time = parse_now("22nd February 2012")
189
+ assert_equal Time.local(2012, 2, 22, 12), time
190
+
191
+ time = parse_now("11th december 79")
192
+ assert_equal Time.local(1979, 12, 11, 12), time
193
+ end
194
+
195
+ def test_handle_sd_rmn_sy
162
196
  time = parse_now("3 jan 2010")
163
197
  assert_equal Time.local(2010, 1, 3, 12), time
164
198
 
@@ -167,36 +201,29 @@ class TestParsing < Test::Unit::TestCase
167
201
 
168
202
  time = parse_now("27 Oct 2006 7:30pm")
169
203
  assert_equal Time.local(2006, 10, 27, 19, 30), time
204
+ end
170
205
 
171
- # sm_sd_sy
172
-
206
+ def test_handle_sm_sd_sy
173
207
  time = parse_now("5/27/1979")
174
208
  assert_equal Time.local(1979, 5, 27, 12), time
175
209
 
176
210
  time = parse_now("5/27/1979 4am")
177
211
  assert_equal Time.local(1979, 5, 27, 4), time
178
212
 
179
- # sd_sm_sy
213
+ # month day overflows
214
+ time = parse_now("30/2/2000")
215
+ assert_nil time
216
+ end
180
217
 
218
+ def test_handle_sd_sm_sy
181
219
  time = parse_now("27/5/1979")
182
220
  assert_equal Time.local(1979, 5, 27, 12), time
183
221
 
184
222
  time = parse_now("27/5/1979 @ 0700")
185
223
  assert_equal Time.local(1979, 5, 27, 7), time
224
+ end
186
225
 
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
-
226
+ def test_handle_sy_sm_sd
200
227
  time = parse_now("2000-1-1")
201
228
  assert_equal Time.local(2000, 1, 1, 12), time
202
229
 
@@ -218,43 +245,73 @@ class TestParsing < Test::Unit::TestCase
218
245
  time = parse_now("2006-08-20 15:30.30")
219
246
  assert_equal Time.local(2006, 8, 20, 15, 30, 30), time
220
247
 
221
- # rdn_rm_rd_rt_rtz_ry
248
+ time = parse_now("1902-08-20")
249
+ assert_equal Time.local(1902, 8, 20, 12, 0, 0), time
250
+ end
222
251
 
223
- time = parse_now("Mon Apr 02 17:00:00 PDT 2007")
224
- assert_equal 1175558400, time.to_i
252
+ def test_handle_sm_sy
253
+ time = parse_now("05/06")
254
+ assert_equal Time.local(2006, 5, 16, 12), time
225
255
 
226
- now = Time.now
227
- time = parse_now(now.to_s)
228
- # assert_equal now.to_s, time.to_s
256
+ time = parse_now("12/06")
257
+ assert_equal Time.local(2006, 12, 16, 12), time
229
258
 
230
- # rm_sd_rt
259
+ time = parse_now("13/06")
260
+ assert_equal nil, time
261
+ end
231
262
 
232
- #time = parse_now("jan 5 13:00")
233
- #assert_equal Time.local(2007, 1, 5, 13), time
263
+ def test_handle_r
264
+ end
234
265
 
235
- # old dates
266
+ def test_handle_r_g_r
267
+ end
236
268
 
237
- time = parse_now("may 40")
238
- assert_equal Time.local(2040, 5, 16, 12, 0, 0), time
269
+ def test_handle_srp
270
+ end
239
271
 
240
- time = parse_now("may 27 40")
241
- assert_equal Time.local(2040, 5, 27, 12, 0, 0), time
272
+ def test_handle_s_r_p
273
+ end
242
274
 
243
- time = parse_now("1800-08-20")
244
- assert_equal Time.local(1800, 8, 20, 12, 0, 0), time
275
+ def test_handle_p_s_r
245
276
  end
246
277
 
247
- def test_parse_two_digit_years
248
- time = parse_now("may 97")
249
- assert_equal Time.local(1997, 5, 16, 12), time
278
+ def test_handle_s_r_p_a
279
+ end
250
280
 
251
- time = parse_now("may 1st 01")
252
- assert_equal Time.local(2001, 5, 1, 12), time
281
+ def test_handle_orr
282
+ end
283
+
284
+ def test_handle_o_r_s_r
285
+ time = parse_now("3rd wednesday in november")
286
+ assert_equal Time.local(2006, 11, 15, 12), time
253
287
 
254
- time = parse_now("may 79", :ambiguous_year_future_bias => 10)
255
- assert_equal Time.local(2079, 5, 16, 12), time
288
+ time = parse_now("10th wednesday in november")
289
+ assert_equal nil, time
290
+
291
+ # time = parse_now("3rd wednesday in 2007")
292
+ # assert_equal Time.local(2007, 1, 20, 12), time
256
293
  end
257
294
 
295
+ def test_handle_o_r_g_r
296
+ time = parse_now("3rd month next year", :guess => false)
297
+ assert_equal Time.local(2007, 3), time.begin
298
+
299
+ time = parse_now("3rd month next year", :guess => false)
300
+ assert_equal Time.local(2007, 3, 1), time.begin
301
+
302
+ time = parse_now("3rd thursday this september")
303
+ assert_equal Time.local(2006, 9, 21, 12), time
304
+
305
+ now = Time.parse("1/10/2010")
306
+ time = parse_now("3rd thursday this november", :now => now)
307
+ assert_equal Time.local(2010, 11, 18, 12), time
308
+
309
+ time = parse_now("4th day last week")
310
+ assert_equal Time.local(2006, 8, 9, 12), time
311
+ end
312
+
313
+ # end of testing handlers
314
+
258
315
  def test_parse_guess_r
259
316
  time = parse_now("friday")
260
317
  assert_equal Time.local(2006, 8, 18, 12), time
@@ -274,6 +331,12 @@ class TestParsing < Test::Unit::TestCase
274
331
  time = parse_now("13:45")
275
332
  assert_equal Time.local(2006, 8, 17, 13, 45), time
276
333
 
334
+ time = parse_now("1:01pm")
335
+ assert_equal Time.local(2006, 8, 16, 13, 01), time
336
+
337
+ time = parse_now("2:01pm")
338
+ assert_equal Time.local(2006, 8, 16, 14, 01), time
339
+
277
340
  time = parse_now("november")
278
341
  assert_equal Time.local(2006, 11, 16), time
279
342
  end
@@ -643,17 +706,6 @@ class TestParsing < Test::Unit::TestCase
643
706
  # future
644
707
  end
645
708
 
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
709
  def test_parse_guess_o_r_g_r
658
710
  time = parse_now("3rd month next year", :guess => false)
659
711
  assert_equal Time.local(2007, 3), time.begin
@@ -731,11 +783,11 @@ class TestParsing < Test::Unit::TestCase
731
783
  end
732
784
 
733
785
  def test_argument_validation
734
- assert_raise(Chronic::InvalidArgumentException) do
786
+ assert_raise(ArgumentError) do
735
787
  time = Chronic.parse("may 27", :foo => :bar)
736
788
  end
737
789
 
738
- assert_raise(Chronic::InvalidArgumentException) do
790
+ assert_raise(ArgumentError) do
739
791
  time = Chronic.parse("may 27", :context => :bar)
740
792
  end
741
793
  end
metadata CHANGED
@@ -1,42 +1,41 @@
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.0
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-07-19 00:00:00.000000000 +01:00
14
+ default_executable:
15
15
  dependencies: []
16
-
17
16
  description: Chronic is a natural language date/time parser written in pure Ruby.
18
- email:
17
+ email:
19
18
  - tom@mojombo.com
20
19
  - lee@jarvis.co
21
20
  executables: []
22
-
23
21
  extensions: []
24
-
25
- extra_rdoc_files:
22
+ extra_rdoc_files:
26
23
  - README.md
27
24
  - HISTORY.md
28
25
  - LICENSE
29
- files:
26
+ files:
27
+ - .gemtest
28
+ - .gitignore
29
+ - .yardopts
30
30
  - HISTORY.md
31
31
  - LICENSE
32
- - Manifest.txt
33
32
  - README.md
34
33
  - Rakefile
35
- - benchmark/benchmark.rb
36
34
  - chronic.gemspec
37
35
  - lib/chronic.rb
38
36
  - lib/chronic/chronic.rb
39
37
  - lib/chronic/grabber.rb
38
+ - lib/chronic/handler.rb
40
39
  - lib/chronic/handlers.rb
41
40
  - lib/chronic/mini_date.rb
42
41
  - lib/chronic/numerizer.rb
@@ -60,6 +59,7 @@ files:
60
59
  - lib/chronic/repeaters/repeater_weekend.rb
61
60
  - lib/chronic/repeaters/repeater_year.rb
62
61
  - lib/chronic/scalar.rb
62
+ - lib/chronic/season.rb
63
63
  - lib/chronic/separator.rb
64
64
  - lib/chronic/span.rb
65
65
  - lib/chronic/tag.rb
@@ -77,43 +77,43 @@ files:
77
77
  - test/test_RepeaterMinute.rb
78
78
  - test/test_RepeaterMonth.rb
79
79
  - test/test_RepeaterMonthName.rb
80
+ - test/test_RepeaterSeason.rb
80
81
  - test/test_RepeaterTime.rb
81
82
  - test/test_RepeaterWeek.rb
82
83
  - test/test_RepeaterWeekday.rb
83
84
  - test/test_RepeaterWeekend.rb
84
85
  - test/test_RepeaterYear.rb
85
86
  - test/test_Span.rb
86
- - test/test_Time.rb
87
87
  - test/test_Token.rb
88
88
  - test/test_parsing.rb
89
+ has_rdoc: true
89
90
  homepage: http://github.com/mojombo/chronic
90
91
  licenses: []
91
-
92
92
  post_install_message:
93
- rdoc_options:
93
+ rdoc_options:
94
94
  - --charset=UTF-8
95
- require_paths:
95
+ require_paths:
96
96
  - lib
97
- required_ruby_version: !ruby/object:Gem::Requirement
97
+ required_ruby_version: !ruby/object:Gem::Requirement
98
98
  none: false
99
- requirements:
100
- - - ">="
101
- - !ruby/object:Gem::Version
102
- version: "0"
103
- required_rubygems_version: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - ! '>='
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
103
+ required_rubygems_version: !ruby/object:Gem::Requirement
104
104
  none: false
105
- requirements:
106
- - - ">="
107
- - !ruby/object:Gem::Version
108
- version: "0"
105
+ requirements:
106
+ - - ! '>='
107
+ - !ruby/object:Gem::Version
108
+ version: '0'
109
109
  requirements: []
110
-
111
110
  rubyforge_project: chronic
112
- rubygems_version: 1.8.2
111
+ rubygems_version: 1.6.2
113
112
  signing_key:
114
113
  specification_version: 3
115
114
  summary: Natural language date/time parsing.
116
- test_files:
115
+ test_files:
116
+ - test/helper.rb
117
117
  - test/test_Chronic.rb
118
118
  - test/test_DaylightSavings.rb
119
119
  - test/test_Handler.rb
@@ -125,12 +125,12 @@ test_files:
125
125
  - test/test_RepeaterMinute.rb
126
126
  - test/test_RepeaterMonth.rb
127
127
  - test/test_RepeaterMonthName.rb
128
+ - test/test_RepeaterSeason.rb
128
129
  - test/test_RepeaterTime.rb
129
130
  - test/test_RepeaterWeek.rb
130
131
  - test/test_RepeaterWeekday.rb
131
132
  - test/test_RepeaterWeekend.rb
132
133
  - test/test_RepeaterYear.rb
133
134
  - test/test_Span.rb
134
- - test/test_Time.rb
135
135
  - test/test_Token.rb
136
136
  - 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
data/test/test_Time.rb DELETED
@@ -1,49 +0,0 @@
1
- require File.join(File.dirname(__FILE__), *%w[helper])
2
-
3
- class TestTime < Test::Unit::TestCase
4
-
5
- def setup
6
- end
7
-
8
- def test_normal
9
- assert_equal Time.local(2006, 1, 2, 0, 0, 0), Time.construct(2006, 1, 2, 0, 0, 0)
10
- assert_equal Time.local(2006, 1, 2, 3, 0, 0), Time.construct(2006, 1, 2, 3, 0, 0)
11
- assert_equal Time.local(2006, 1, 2, 3, 4, 0), Time.construct(2006, 1, 2, 3, 4, 0)
12
- assert_equal Time.local(2006, 1, 2, 3, 4, 5), Time.construct(2006, 1, 2, 3, 4, 5)
13
- end
14
-
15
- def test_second_overflow
16
- assert_equal Time.local(2006, 1, 1, 0, 1, 30), Time.construct(2006, 1, 1, 0, 0, 90)
17
- assert_equal Time.local(2006, 1, 1, 0, 5, 0), Time.construct(2006, 1, 1, 0, 0, 300)
18
- end
19
-
20
- def test_minute_overflow
21
- assert_equal Time.local(2006, 1, 1, 1, 30), Time.construct(2006, 1, 1, 0, 90)
22
- assert_equal Time.local(2006, 1, 1, 5), Time.construct(2006, 1, 1, 0, 300)
23
- end
24
-
25
- def test_hour_overflow
26
- assert_equal Time.local(2006, 1, 2, 12), Time.construct(2006, 1, 1, 36)
27
- assert_equal Time.local(2006, 1, 7), Time.construct(2006, 1, 1, 144)
28
- end
29
-
30
- def test_day_overflow
31
- assert_equal Time.local(2006, 2, 1), Time.construct(2006, 1, 32)
32
- assert_equal Time.local(2006, 3, 5), Time.construct(2006, 2, 33)
33
- assert_equal Time.local(2004, 3, 4), Time.construct(2004, 2, 33)
34
- assert_equal Time.local(2000, 3, 5), Time.construct(2000, 2, 33)
35
-
36
- assert_nothing_raised do
37
- Time.construct(2006, 1, 56)
38
- end
39
-
40
- assert_raise(RuntimeError) do
41
- Time.construct(2006, 1, 57)
42
- end
43
- end
44
-
45
- def test_month_overflow
46
- assert_equal Time.local(2006, 1), Time.construct(2005, 13)
47
- assert_equal Time.local(2005, 12), Time.construct(2000, 72)
48
- end
49
- end