Clever Duration

Super tiny Ruby library for parsing human format of time durations to numbers.

It's far for complete, but it's a good base for future development. Test suit included.

Check tests for a list of supported formats.

Example

duration = CleverDuration.new("1 hour 30 minutes") duration.hours # => 1.5 duration.seconds # => 5400 duration.minutes # => 90

History

The library was extracted from Beanstalk during the awesome Wildbit Open Source Fridays.

Read more about Open Source Fridays here:

http://wildbit.com/blog/2010/01/15/open-source-fridays-at-wildbit/

Copyright (c) 2010 Ilya Sabanin, Wildbit; see LICENSE for details.