lib/nextday/date_extension.rb in nextday-0.1.0 vs lib/nextday/date_extension.rb in nextday-0.2.0

- old
+ new

@@ -40,9 +40,24 @@ next_day end ## + # The previous working day before the current date + # + # @return [Date] Previous Working Day + def previous_working_day + previous_day = to_date - 1 + + # keep going until the next day is a working day + while !previous_day.working_day? + previous_day = previous_day - 1 + end + + previous_day + end + + ## # Is the current date a working day? # # @return [Boolean] def working_day? !weekend? and !public_holiday?