The project is in a healthy, maintained state
The library provides functionality to calculate the expiration from different dates and time objects.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies
 Project Readme

Expiry Calculator

Gem Version Build Code Coverage Maintainability License: MIT

A ruby library that determines how much time left till certain date and time.

Extracted from license manager app.

Installation

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

Usage

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.

API Docs

The gem specs can be found at RubyDocs.

Contributing

Bug reports and pull requests are welcome on GitHub.