Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

ActiveSupport mini-extension to allow adding business_days to time objects.

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 lib
Octocat-spinner-32 spec
Octocat-spinner-32 .gitignore
Octocat-spinner-32 LICENSE
Octocat-spinner-32 README.rdoc
Octocat-spinner-32 Rakefile
README.rdoc

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"

Current Limitations

  • Holidays are completely ignored.

  • 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.

Something went wrong with that request. Please try again.