module JpStockRule::DateExtensions::InstanceMethods

Public Instance Methods

jpx_business_day?() click to toggle source

Returns it is a business day or not.

# File lib/jp_stock_rule/date_extensions.rb, line 10
def jpx_business_day?
  return false if HOLIDAY_WDAYS.include?(wday)
  return false if YEAR_END_AND_NEW_YEAR_HOLIDAYS.include?([month, day])
  return !HolidayJp.holiday?(self)
end
next_jpx_business_day(days = 1) click to toggle source

Returns a next business day.

# File lib/jp_stock_rule/date_extensions.rb, line 17
def next_jpx_business_day(days = 1)
  raise ArgumentError, "days must be >= 0" if days < 0
  next_day = self
  while days > 0
    next_day += 1
    days -= 1 if next_day.jpx_business_day?
  end
  next_day
end