Home

Awesome

Chronic Between

A simple Ruby natural language parser for date and time ranges. (For example, Mon-Fri 09:00-16:30, etc.) Returns a boolean result.

Several date and time ranges can be supplied with matching patterns being separated by a comma.

Installation

$ sudo gem sources -a http://gemcutter.org
$ sudo gem install chronic_between

Usage

>> s = 'Mon-Fri 9:00-16:30, Saturday, Sunday'
>> c = ChronicBetween.new(s)

>> DateTime.now      
=> #<DateTime: 2011-03-26T16:54:40+00:00

>> c.within? DateTime.now
=> true

>> c.within? DateTime.parse("28-Mar-2011 14:33")
=> true

>> c.within? DateTime.parse("28-Mar-2011 08:33")
=> false

Examples of parse-able strings: