Class: Date

Inherits:
Object
  • Object
show all
Defined in:
lib/business_time/core_ext/date.rb

Overview

Add workday and weekday concepts to the Date class

Instance Method Summary collapse

Instance Method Details

#business_days_until(to_date) ⇒ Object



11
12
13
# File 'lib/business_time/core_ext/date.rb', line 11

def business_days_until(to_date)
  (self...to_date).select{ |day| day.workday? }.size
end

#weekday?Boolean

Returns:

  • (Boolean)


7
8
9
# File 'lib/business_time/core_ext/date.rb', line 7

def weekday?
  BusinessTime::Config.weekdays.include? self.wday
end

#workday?Boolean

Returns:

  • (Boolean)


3
4
5
# File 'lib/business_time/core_ext/date.rb', line 3

def workday?
  self.weekday? && !BusinessTime::Config.holidays.include?(self)
end