lib/date_utils.rb
# get last 1st or 3rd Tuesday of the month

get last 1st or 3rd Tuesday of the month
get last 1st or 3rd Tuesday of the month
def last_update_tuesday(date)
      date = date.to_date
      begin_of_the_month = Date.new(date.year, date.month, 1)
      begin_of_the_month_first_tuesday = first_weekday_of_the_month(begin_of_the_month, 2)
      begin_of_the_last_month = begin_of_the_month << 1
      begin_of_the_last_month_first_tuesday = first_weekday_of_the_month(begin_of_the_last_month, 2)
      candidate_tuesdays = [
        begin_of_the_last_month_first_tuesday,
        begin_of_the_last_month_first_tuesday + 14,
        begin_of_the_month_first_tuesday,
        begin_of_the_month_first_tuesday + 14,
      ]
      candidate_tuesdays.select { |tuesday| tuesday <= date }.last
    end
def last_update_tuesday ( date ) date = date . to_date begin_of_the_month = Date . new ( date . year , date . month , 1 ) begin_of_the_month_first_tuesday = first_weekday_of_the_month ( begin_of_the_month , 2 ) begin_of_the_last_month = begin_of_the_month << 1 begin_of_the_last_month_first_tuesday = first_weekday_of_the_month ( begin_of_the_last_month , 2 ) candidate_tuesdays = [ begin_of_the_last_month_first_tuesday , begin_of_the_last_month_first_tuesday + 14 , begin_of_the_month_first_tuesday , begin_of_the_month_first_tuesday + 14 , ] candidate_tuesdays . select { | tuesday | tuesday <= date } . last end
get last 1st or 3rd Tuesday of the month
get last 1st or 3rd Tuesday of the month
date
<not_specific>