Sha256: fa6947d9acf0012e4f9f90230c9cd7661cbd05b18b17dde4217ed02f63c9a33a

Contents?: true

Size: 957 Bytes

Versions: 1

Compression:

Stored size: 957 Bytes

Contents

Chronic Duration
================

A simple Ruby natural language parser for elapsed time. (For example, 4 hours and 30 minutes, 6 minutes 4 seconds, 3 days, etc.) Returns all results in seconds. Will return an integer unless you get tricky and need a float. (4 minutes and 13.47 seconds, for example.)

Installation
------------

    $ sudo gem sources -a http://gems.github.com
    $ sudo gem install hpoydar-chronic_duration

Usage
-----

    >> require 'chronic_duration'
    => true
    >> ChronicDuration.parse('4 minutes and 30 seconds')
    => 270
    
Nil is returned if the string can't be parsed

Examples of parse-able strings:

* '12.4 secs'
* '1:20' 
* '1:20.51'
* '4:01:01'
* '3 mins 4 sec'
* '2 hrs 20 min'
* '2h20min'
* '6 mos 1 day'
* '47 yrs 6 mos and 4d'

    
TODO
----

* Benchmark and optimize
* Context specific matching (E.g., for '4m30s', assume 'm' is minutes)
* Smartly parse vacation-like durations (E.g., '4 days and 3 nights')

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
hpoydar-chronic_duration-0.2.0 README