Chronic
DESCRIPTION
Chronic is a natural language date/time parser written in pure Ruby. Chronic L10n aims to add translations to Chronics abilities.
INSTALLATION
WARNING: This gem will only work when and IF this fork of chronic gets merged and released. Meanwhile you can install the chronic gem from the forks source to get it going.
RubyGems
$ [sudo] gem install chronic-l10n
GitHub
$ git clone git://github.com/luan/chronic-l10n.git
$ cd chronic-l10n && gem build chronic-l10n.gemspec
$ gem install chronic-l10n-<version>.gem
USAGE
You can parse strings containing a natural language date using the
Chronic.parse
method.
require 'chronic'
require 'chronic-l10n'
Time.now #=> Sun Aug 27 23:18:25 PDT 2006
Chronic.locale = :'pt-BR'
Chronic.parse('amanhã')
#=> Mon Aug 28 12:00:00 PDT 2006
Chronic.parse('segunda', :context => :past)
#=> Mon Aug 21 12:00:00 PDT 2006
Chronic.parse('essa terça 5:00')
#=> Tue Aug 29 17:00:00 PDT 2006
Chronic.parse('essa terça 5:00', :ambiguous_time_range => :none)
#=> Tue Aug 29 05:00:00 PDT 2006
Chronic.parse('27 de maio', :now => Time.local(2000, 1, 1))
#=> Sat May 27 12:00:00 PDT 2000
Chronic.parse('27 de maio', :guess => false)
#=> Sun May 27 00:00:00 PDT 2007..Mon May 28 00:00:00 PDT 2007
Chronic.parse('6/4/2012', :endian_precedence => :little)
#=> Fri Apr 06 00:00:00 PDT 2012
See Chronic.parse
for detailed usage instructions.
CONTRIBUTE
You might like to add your language or improve some already available language, start by forking the repo on GitHub:
https://github.com/luan/chronic-l10n
The best way to get your changes merged back into core is as follows:
- Clone down your fork
- Create a thoughtfully named topic branch to contain your change
- Hack away
- Add tests and make sure everything still passes by running
rake
- Ensure your tests pass in multiple timezones. ie
TZ=utc rake
TZ=BST rake
- If you are adding new functionality, document it in the README
- Do not change the version number, we will do that on our end
- If necessary, rebase your commits into logical chunks, without errors
- Push the branch up to GitHub
- Send a pull request for your branch