public
Description: bringing da chronic to your rails models
Homepage: http://b.logi.cx/2008/2/8/gettin-less-icky-with-the-chronic
Clone URL: git://github.com/flogic/autochronic.git
Search Repo:
Added license file and filled out readme. This may be premature, but I 
wanted a good place to record my Chronic.parse('today') adventures.
ymendel (author)
Thu Feb 07 21:39:41 -0800 2008
commit  c1e111595bc0032831a97f6f3a94eeaffc9e110a
tree    2e24cb5fd678184381a36bc19769e53a47029d44
parent  52bdad5cd599979d5a0d867f527357aa8aa60870
0
...
1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
...
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
0
@@ -1 +1,44 @@
0
-initial commit
0
+= Autochronic
0
+<b>Version 0.2.0 (7 Feb, 2008)</b>
0
+
0
+Author:: Yossef Mendelssohn (ymendel@pobox.com)
0
+Copyright:: Copyright (c) 2008, Flawed Logic, OG Consulting, Yossef Mendelssohn
0
+License:: MIT License. See MIT-LICENSE file for more details.
0
+
0
+Autochronic is a Ruby on Rails that will automatically make any date or datetime attribute in any model automatically handle natural-language strings. There is no effort on your part, no creation of before_save callbacks or writing your own accessors to handle the special input.
0
+
0
+== Installation
0
+
0
+Unpack the autochronic directory into vendor/rails/ in your rails project.
0
+A definitive public revision control access point is forthcoming that will make it possible to install the plugin via script/plugin install.
0
+
0
+== Using Autochronic
0
+
0
+Just use your models normally. They'll do the work for you automatically. Automatic Chronic. Auto Chronic. Autochronic.
0
+
0
+== Version history:
0
+
0
+ 0.2.0 - Initial release
0
+ Developed under Rails 2.0.2 using chronic 0.2.3. That worked for me, and I'm not making any guarantees for anything else.
0
+
0
+== Known issues:
0
+
0
+ Chronic's parsing of 'today' is time-dependent in a bad way. See the following irb dump.
0
+
0
+ >> Chronic.parse('today')
0
+ => Fri Feb 08 00:00:00 -0600 2008
0
+ >> Date.today.to_s
0
+ => "2008-02-07"
0
+ >> Time.now
0
+ => Thu Feb 07 23:13:28 -0600 2008
0
+ More info:
0
+ >> Time.local(2008, 2, 7, 22, 59, 59)
0
+ => Thu Feb 07 22:59:59 -0600 2008
0
+ >> time1 = _
0
+ => Thu Feb 07 22:59:59 -0600 2008
0
+ >> time2 = Time.local(2008, 2, 7, 23, 0, 0)
0
+ => Thu Feb 07 23:00:00 -0600 2008
0
+ >> Chronic.parse('today', :now => time1)
0
+ => Thu Feb 07 23:30:00 -0600 2008
0
+ >> Chronic.parse('today', :now => time2)
0
+ => Fri Feb 08 00:00:00 -0600 2008
...
28
29
30
31
32
33
34
35
36
37
38
39
...
28
29
30
 
 
 
 
 
 
31
32
33
0
@@ -28,12 +28,6 @@ describe SpaceCowboy do
0
     end
0
     
0
     # WTF: this is presently giving me the next day
0
- # >> Chronic.parse('today')
0
- # => Fri Feb 08 00:00:00 -0600 2008
0
- # >> Date.today.to_s
0
- # => "2008-02-07"
0
- # >> Time.now
0
- # => Thu Feb 07 23:13:28 -0600 2008
0
     it 'should accept a natural language date string' do
0
       date = Date.today
0
       date_input = 'today'

Comments

    No one has commented yet.