Ruby on Rails latest stable (v4.0.2) - 2 notes - Class: ActiveSupport::TimeWithZone
between?(min, max) public

Returns true if the current object’s time is within the specified min and max time.

Show source
Register or log in to add new notes.
December 23, 2009 - (<= v2.3.2)
0 thanks

Compare dates

You can check a date resides between two dates.

Date.today.between?(Date.yesterday, Date.tomorrow)

will return true

Date.yesterday.between?(Date.today, Date.tomorrow)

will return false

March 29, 2013
0 thanks

Edge case

Have look how #between? handle adge case. It’s different from DateTime’s.

Date.yesterday.between?(Date.yesterday, Date.tomorrow)
=> true

Date.tomorrow.between?(Date.yesterday, Date.tomorrow)
=> true