Skip to content

Latest commit

 

History

History
31 lines (17 loc) · 1.4 KB

README.rdoc

File metadata and controls

31 lines (17 loc) · 1.4 KB

Kronic

A dirt simple library for parsing human readable dates (Today, Yesterday, Last Monday).

Why not Chronic or Tickle

Chronic and Tickle both parse a heap of formats. That’s not useful to me when they fail on cases I want (14 Sep), and also not useful because I don’t need times or spans. I just want to replace my calendar picker.

In addition, Kronic can take a date and give you a human readable form, neither of which Chronic nor Tickle does.

Oh yeah, Kronic is about 150 lines of code with no dependencies.

Usage

gem install kronic

require 'kronic'
Kronic.parse("Today")     # => Date.today
Kronic.format(Date.today) # => "Today"

Supported formats: Today, yesterday, tomorrow, last thursday, this thursday, 14 Sep, 14 June 2010. Any dates without a year are assumed to be in the past (that’s what my app needs, so that’s what it does).

Compatibility

Kronic does not require ActiveSupport, but if it is present Kronic will use the current time zone. In short, everything should work as you would expect.

Kronic is tested on 1.8.7, 1.9.2, Rubinius, and JRuby.

Future

Current release is a release candidate for 1.0, when the API will be declared stable. i18n work has been started in a branch, and also in yolk’s fork. I’m not using this personally. Maybe also a flag to toggle the interpretation of dates without years would be nice. Neither of those things will be in 1.0 I don’t reckon.