Skip to content

Instantly share code, notes, and snippets.

@mdarby
Created January 4, 2009 16:13
Show Gist options
  • Save mdarby/43093 to your computer and use it in GitHub Desktop.
Save mdarby/43093 to your computer and use it in GitHub Desktop.
# Usage: Date.today.weekdays_until(some_date_in_the_future)
class Date
def weekdays_until(date)
return 0 if date <= self
(self..date).select{|day| day.is_weekday?}.size
end
def is_weekday?
self.wday != 0 && self.wday != 6
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment