No commit activity in last 3 years
No release in over 3 years
It adds the methods (before?, after?, within_last?, within_coming?) to Time
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.8.4
~> 3.12
~> 2.8.0
 Project Readme

before_and_after

befoce_and_after adds the methods (before?, after?, within_last?, within_coming?) to Time

2.minutes.ago.after?(Time.now) # => false

Time.now.before?(2.hours.from_now) # => true

2.minutes.ago.within_last?(2.hours) # => true

2.minutes.from_now.within_coming?(2.hours) # => true

Example of where it really improves readability

email.sent_at.within_last?(48.hours)

vs

email.sent_at > Time.now - 48.hours

Credits goes to whoever wrote this. http://www.dzone.com/snippets/and-after-ruby-time-class

Changelog

1.0.4

  • Removing puts used during testing

1.0.3

  • Yet another try to get ActiveSupport::TimeWithZone to work with before_and_after

1.0.2

  • Fixed problem with ActiveSupport::TimeWithZone between not behaving the same as Time#between

1.0.1

  • Fixed so that we always use the same time NOW

Copyright

Copyright (c) 2013 - 2014 Björn Blomqvist. See LICENSE.txt for further details.