Handles time differences and calculations.
Add this line to your application's Gemfile:
gem 'moments'
And then execute:
$ bundle
Or install it yourself as:
$ gem install moments
require 'moments'
t1 = Time.new 2015, 1, 1, 0, 0, 0
t2 = Time.now # 2020, 8, 6, 19, 29, 6
diff = Moments.difference t1, t2
puts diff.to_hash
# { years: 5, months: 7, days: 5, hours: 19, minutes: 29, seconds: 6 }
puts diff.in_months
# 67 (5 * 12 + 7)
# there are also methods for each component
- Fork it ( https://github.com/excpt/moments/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