In my Rails application, I need to find if a given date is the second or fourth Saturday of the month. What's the efficient way to do this? Is there a gem I can use?
This checks if the day is a saturday and the zero-based week number is odd (1 or 3 in our case) :
def second_or_fourth_saturday?(date) date.saturday? && ((date.day - 1) / 7).odd? end