Created
August 29, 2012 01:05
-
-
Save cemeng/3505795 to your computer and use it in GitHub Desktop.
business days
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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