Skip to content

Instantly share code, notes, and snippets.

@isaacsanders
Forked from mdarby/gist:1297199
Created October 19, 2011 00:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save isaacsanders/1297210 to your computer and use it in GitHub Desktop.
Save isaacsanders/1297210 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