Module: ActiveSupport::CoreExtensions::Time::Calculations

Included in:
Time
Defined in:
lib/weekdays.rb

Overview

Enables the use of time calculations within Time itself

Instance Method Summary collapse

Instance Method Details

#weekday?Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/weekdays.rb', line 30

def weekday?
  (1..5).include?(wday)
end

#weekdays_until(date) ⇒ Object



34
35
36
37
# File 'lib/weekdays.rb', line 34

def weekdays_until(date)
  return 0 if date <= self.to_date
  (self.to_date...date).select{|day| day.weekday?}.size
end