module UsBankHolidays

Constants

VERSION

Public Class Methods

bank_holiday?(date, include_weekends = true) click to toggle source

Returns true if the given date is a bank holiday, false otherwise. Pass the optional 'include_weekends' to control whether weekends should count as bank holidays (default is true). If include_weekends is set to false but the date is a Federal bank holiday, returns true (Ex: 4th of July, 2015, Christmas Day 2016)

# File lib/us_bank_holidays.rb, line 19
def self.bank_holiday?(date, include_weekends = true)
  if include_weekends && weekend?(date)
    true
  else
    ::UsBankHolidays::HolidayYear.new(date.year).bank_holidays.include?(date)
  end
end
banking_day?(date) click to toggle source

Returns true if the given date is a banking day, i.e. is not a bank holiday, false otherwise.

# File lib/us_bank_holidays.rb, line 29
def self.banking_day?(date)
  !bank_holiday?(date)
end
next_banking_day(date) click to toggle source
# File lib/us_bank_holidays.rb, line 33
def self.next_banking_day(date)
  if (next_date = date + 1).bank_holiday?
    next_banking_day(next_date)
  else
    next_date
  end
end
previous_banking_day(date) click to toggle source
# File lib/us_bank_holidays.rb, line 41
def self.previous_banking_day(date)
  if (previous_date = date - 1).bank_holiday?
    previous_banking_day(previous_date)
  else
    previous_date
  end
end
saturday_holiday_date_rolling?() click to toggle source

If enabled (ENV), a Friday that falls a day before a Saturday that's a bank holiday is considered a bank holiday

# File lib/us_bank_holidays.rb, line 51
def self.saturday_holiday_date_rolling?
  !!ENV["NO_FRIDAY_HOLIDAY_ACH"]
end
weekend?(date) click to toggle source

Returns true if the given date is a weekend, false otherwise.

# File lib/us_bank_holidays.rb, line 10
def self.weekend?(date)
  date.sunday? || date.saturday?
end