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
- Host: GitHub
- URL: https://github.com/colevoss/sincewhen
- Owner: colevoss
- License: mit
- Created: 2013-10-15T22:38:52.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2014-05-15T05:47:54.000Z (about 12 years ago)
- Last Synced: 2024-04-26T01:21:06.060Z (about 2 years ago)
- Language: Ruby
- Homepage:
- Size: 187 KB
- Stars: 0
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
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