日本の法律に則った年齢計算です 年齢計算ニ関スル法律 - Wikipedia
年を取る日は誕生日の前日となる
Add this line to your application's Gemfile:
gem 'age_jp'
And then execute:
$ bundle
Or install it yourself as:
$ gem install age_jp
Timecop.freeze(Time.new(2014, 12, 31))
birthday = Date.new(2000, 1, 1)
birthday.age # 14 (通常の年齢)
birthday.age_at(Date.today) # same as birthday.age
birthday.age_jp # 15 (日本の法律準拠)
birthday.age_jp_at(Date.today) # same as birthday.age_jp
birthday.east_asian_age_reckoning # 15 (数え年)
birthday.east_asian_age_reckoning_at(Date.today) # same as birthday.east_asian_age_reckoning
birthday.insurance_age # 14 (保険年齢)
birthday.insurance_age_at(Date.today) # same as birthday.insurance_age
birthday.to_years_old(17) # 2017/01/01. 17歳の誕生日を返却
birthday.to_years_old_jp(17) # 2016/12/31. 17歳の年齢加算日(日本の法律準拠)を返却
- Fork it ( https://github.com/[my-github-username]/age_jp/fork )
- 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 a new Pull Request