0.01
No commit activity in last 3 years
No release in over 3 years
Having trouble figuring out which date is in the future looking at > or < ?
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

 Project Readme

Time Predicates

Build Status Code Climate GPA

Comparing dates and time gives me a headache every single time and I need to resolve to drawing timelines in order to determine if the > sign means that a date is in the future or the past in relation to the other one.

This little gem adds several helper predicates to Time and Date classes (and all classes that inherit from them, e.g. DateTime in rails), that help in writing and reading such conditions.

Install

$ gem install time-predicates

or add to your Gemfile

gem "time-predicates"

Description

Following predicate methods are available:

  • Date.parse("2016-03-05").after?(Date.parse('2016-03-04'))
  • Date.parse("2016-03-05").after_or_equal?(Date.parse("2016-03-05"))
  • Date.parse('2016-03-04').before?(Date.parse("2016-03-05"))
  • Date.parse('2016-03-04').before_or_equal?(Date.parse('2016-03-04'))

The method names are pretty self-explanatory.

Copyright

Copyright (c) 2016 Szymon Szeliga

See LICENSE for details.