0.0
Repository is archived
No commit activity in last 3 years
No release in over 3 years
Write me...
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

 Project Readme

business_days¶ ↑

Business Days is a sort-of extension to ActiveSupport to allow adding business days to time objects.

Installation¶ ↑

Add a config.gem line (rails 2.3)

config.gem 'business_days'

Or add it to your Gemfile.

gem 'business_days'

Examples¶ ↑

(Time.parse("Friday") + 1.business_day).strftime("%A")
# => "Monday"

(Time.parse("Friday") + 2.business_days).strftime("%A")
# => "Tuesday"

(Time.parse("Saturday") + 1.business_day).strftime("%A")
# => "Tuesday"

(Time.parse("Saturday") + 0.business_days).strftime("%A")
# => "Monday"

(Time.parse("Friday") - 1.business_day).strftime("%A")
# => "Thursday"

Holidays¶ ↑

Holidays can be configured by passing in dates:

BusinessDays::Config.holidays = Date.parse("2015-01-01")

You’ll probably want to combine this with the holidays gem and put in to an initializer:

# config/initializers/business_days.rb

BusinessDays::Config.holidays = Holidays.between(Date.today, 1.year.from_now, :us).map do |holiday|
  holiday[:date]
end

Current Limitations¶ ↑

  • Time.now + 123512.business_days is done iteratively, even though it would be fairly straightforward to add (5/7 * n) + or - some small number based on where in the week you started.

  • saturday or sunday + 0.business_days is Monday. There are strong arguments both ways for making this result either monday or saturday. I think Monday is the more helpful. Write me hatemail if you disagree.