= input_chronic
A simple Rack middleware that parses a dates using Chronic, and
returns the result in a standardized manner. The idea is to use
this to verify the input in date input fields using AJAX, to
provide immediate feedback to the user.
== Usage
Include "input_chronic" in your middleware stack. In Rails, this
is done in environment.rb
config.gem 'bjornblomqvist-input_chronic', :lib => 'input_chronic', :source => 'http://gems.github.com'
config.middleware.use "input_chronic"
This will catch requests to /gems.github.com/bjornblomqvist/input_chronic. Use GET requests and
provide a parameter 'date' or 'datetime'. The value will be
parsed by Chronic and returned formatted as 2009-01-01 or
2009-01-01 12:45, depending on the parameter name.
Don't forget to add the javascript found at
/javascript/input_chronic.js
This is also implemented by catching the request before it reaches rails.
To use this on a text input add the class chronic_date or chronic_datetime
<input type="text" class="chronic_datetime" />
== Copyright
Copyright (c) 2009 Erik Hansson, Bjorn Blomqvist. See LICENSE for details.