https://github.com/sixarm/sixarm_ruby_date_age
SixArm.com » Ruby » Date #age_in_years and #age_in_days methods
https://github.com/sixarm/sixarm_ruby_date_age
age date gem ruby
Last synced: 9 months ago
JSON representation
SixArm.com » Ruby » Date #age_in_years and #age_in_days methods
- Host: GitHub
- URL: https://github.com/sixarm/sixarm_ruby_date_age
- Owner: SixArm
- License: other
- Created: 2012-06-09T23:46:37.000Z (about 14 years ago)
- Default Branch: main
- Last Pushed: 2023-09-15T19:27:54.000Z (almost 3 years ago)
- Last Synced: 2025-02-06T00:26:04.901Z (over 1 year ago)
- Topics: age, date, gem, ruby
- Language: Ruby
- Size: 327 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGES.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.md
- Codeowners: CODEOWNERS
Awesome Lists containing this project
README
# SixArm.com → Ruby →
Date age methods
[](http://badge.fury.io/rb/sixarm_ruby_date_age)
[](https://travis-ci.org/SixArm/sixarm_ruby_date_age)
[](https://codeclimate.com/github/SixArm/sixarm_ruby_date_age/maintainability)
* Git:
* Doc:
* Gem:
* Contact: Joel Parker Henderson,
* Project: [changes](CHANGES.md), [license](LICENSE.md), [contributing](CONTRIBUTING.md).
## Introduction
Date extensions to calculate an age in days and years.
Example:
date = Date.today - 400
date.age_in_years #=> 1
date.age_in_days #=> 400
Example of custom dates:
a = Date.new(2000, 10, 31)
b = Date.new(2011, 12, 31)
a.age_in_days_on(b) => 4078
a.age_in_years_on(b) => 11
## Install
### Gem
To install this gem in your shell or terminal:
gem install sixarm_ruby_date_age
### Gemfile
To add this gem to your Gemfile:
gem 'sixarm_ruby_date_age'
### Require
To require the gem in your code:
require 'sixarm_ruby_date_age'