Skip to content

Instantly share code, notes, and snippets.

@mdarby
Created October 19, 2011 00:46
Show Gist options
  • Save mdarby/1297199 to your computer and use it in GitHub Desktop.
Save mdarby/1297199 to your computer and use it in GitHub Desktop.
class MeetingDates
def initialize
@crb_dates = []
@jam_dates = []
calc_meeting_dates
end
def calc_meeting_dates
start_date = Date.today.beginning_of_year
(0..12).inject([]){|s, num| dates_for_month(start_date + num.months)}
end
def dates_for_month(relative_date)
s = relative_date.beginning_of_month
e = relative_date.end_of_month
crb_date = (s..e).select{|d| d.wday == 1}[2] + 18.5.hours
@crb_dates << crb_date
@jam_dates << crb_date + 9.days
end
def next_crb_meeting
@crb_dates.find{|d| d > Time.now}
end
def next_jam_meeting
@jam_dates.find{|d| d > Time.now}
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment