A ruby library that determines how much time left till certain date and time.
Install the gem and add to the application's Gemfile by executing:
bundle add expiry_calculator
If bundler is not being used to manage dependencies, install the gem by executing:
gem install expiry_calculator
Add the library if gem auto loading is not available.
require "expiry_calculator"
You can use the the extendable module method:
ExpiryCalculator.calculate(2025, 10, 10)
# => 201
Or mix in to use the calcuate function directly:
include ExpiryCalculator
calculate Date.new(2025, 10, 10)
# => 201
calculate "2025-01-10"
# => 0
Active record models and be called with the date field needed to calculate:
user = User.first
calculate user, :birth_day
# => 15
The supported objects:
Date
DateTime
string
: attempted to be parsed as datetime object.ActiveRecord
: given an attribute of of the model to read as date object.
The gem specs can be found at RubyDocs.
Bug reports and pull requests are welcome on GitHub.