An open API service indexing awesome lists of open source software.

https://github.com/colevoss/sincewhen

Various Date and Time helpers
https://github.com/colevoss/sincewhen

Last synced: 10 months ago
JSON representation

Various Date and Time helpers

Awesome Lists containing this project

README

          

# 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

1. Fork it
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create new Pull Request