UsBankHolidays
https://github.com/albertosaurus/us_bank_holidays
Patches Date
to make working with US bank holidays easier
Requirements
Tested against the following Ruby runtimes:
- MRI 2.3, 2.4, 2.5
- JRuby 9
- Rubinius (latest)
Installation
Add this line to your application's Gemfile:
gem 'us_bank_holidays'
And then execute:
$ bundle install
Or install it yourself as:
$ gem install us_bank_holidays
Usage
First, load the gem.
require 'us_bank_holidays'
This adds the following features to dates.
date = Date.new(2014, 1, 3)
date.bank_holiday?
date.weekend?
date.next_banking_day
date.banking_day?
date.first_banking_day_of_month?
date.last_banking_day_of_month?
Date.new(2014, 1, 16).add_banking_days(2)
Date.new(2014, 1, 5).previous_banking_day
By default, weekends always count as bank holidays, but this can be disabled.
date = Date.new(2014, 2, 2)
date.bank_holiday?
date.bank_holiday?(false)
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Make sure all your changes are covered by tests
- Push to the branch (
git push origin my-new-feature
) - Create new Pull Request