Module: SimplesIdeias::Recurrence::Handler::FallBack

Defined in:
lib/recurrence/handler/fall_back.rb

Overview

If the given date is invalid - beyond the end of the month - then this will move the day back to the last day of the given month.

Examples

FallBack.call(1, 1, 2011)
# => January 1, 2011

FallBack.call(31, 2, 2011)
# => February 28, 2011

Class Method Summary collapse

Class Method Details

.call(day, month, year) ⇒ Object



17
18
19
# File 'lib/recurrence/handler/fall_back.rb', line 17

def self.call(day, month, year)
  Date.new(year, month, [day, Time.days_in_month(month, year)].min)
end