SinceWhen
Returns a string containing the amount of time since the date given with varying scopes of specificy.
**Currently on the drawing board:
- Support for weeks
Installation
Add this line to your application's Gemfile:
gem 'since_when'
And then execute:
$ bundle
Or install it yourself as:
$ gem install since_when
Usage
SinceWhen::time_since( date, :scope = optional )
- date can be a Date object, DateTime object, or anything else that can be turned into a DateTime object (ie. ActiveSupport::TimeWithZone)
- Scope can be any of the following:
- :year
- :month (default)
- :day
- :hour
- :minute
- :second
Example:
example_date = Date.new(2001, 2, 3)
SinceWhen::time_since( example_date, :month )
>> "12 years 8 months"
# or
SinceWhen::time_since( example_date, :day)
>> "12 years 8 months 12 days"
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin my-new-feature) - Create new Pull Request