Skip to content

Instantly share code, notes, and snippets.

@ovoice
Created September 14, 2009 20:45
Show Gist options
  • Save ovoice/186918 to your computer and use it in GitHub Desktop.
Save ovoice/186918 to your computer and use it in GitHub Desktop.
module ApplicationHelper
# A simple helper counting/calculating business days from_now in ruby on rails
# from a desired time interval (i.e. ten business days from now)
def business_days_from_now(interval=10)
business_days = 0
total_days = 0
while business_days < interval
total_days+=1
business_days += 1 unless [0, 6].include?(total_days.days.from_now.wday)
end
total_days.days.from_now.strftime('%D')
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment