Skip to content

Instantly share code, notes, and snippets.

@cemeng
Created August 29, 2012 01:05
Show Gist options
  • Save cemeng/3505795 to your computer and use it in GitHub Desktop.
Save cemeng/3505795 to your computer and use it in GitHub Desktop.
business days
# stolen from business_time gem
def self.business_days_from(start_date=Time.zone.now.to_date, business_days)
end_date = start_date
days = business_days
while days > 0 || !HouseOrder.workday?(end_date)
days -= 1 if HouseOrder.workday?(end_date)
end_date = end_date + 1.day
end
end_date
end
def self.workday?(date)
(0..5).include?date.wday
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment