Skip to content

Instantly share code, notes, and snippets.

@mokolabs
Forked from notch8/snippet.rb
Created July 2, 2010 21:32
Show Gist options
  • Save mokolabs/461936 to your computer and use it in GitHub Desktop.
Save mokolabs/461936 to your computer and use it in GitHub Desktop.
def next_meeting(now=1.day.from_now)
if Chronic.parse("1st thursday of this month", :context => :past, :now => now)
return Chronic.parse('1st thursday of next month', :now => now)
else
return Chronic.parse("1st thursday of this month", :now => now)
end
end
@mokolabs
Copy link
Author

mokolabs commented Jul 2, 2010

def next_meeting_date
if (Time.now.beginning_of_day) < Chronic.parse("1st thursday in #{Time.now.strftime("%B").downcase}")
Chronic.parse("1st thursday in #{Time.now.strftime("%B").downcase}")
else
Chronic.parse('1st thursday next month')
end
end

@notch8
Copy link

notch8 commented Jul 2, 2010

def next_meeting(now=Time.now)
now -= 1.day
if Chronic.parse("1st thursday of this month", :context => :past, :now => now)
return Chronic.parse('1st thursday of next month', :now => now)
else
return Chronic.parse("1st thursday of this month", :now => now)
end
end

@bensie
Copy link

bensie commented Jul 2, 2010

Nice, way better.

@bensie
Copy link

bensie commented Jul 3, 2010

Just checked out that gem, never used it before. Very cool.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment