Module: Workdays

Defined in:
lib/workdays/time_extensions.rb,
lib/workdays.rb,
lib/workdays/version.rb

Overview

This module contains methods to help with dates

Defined Under Namespace

Modules: TimeExtensions

Constant Summary collapse

VERSION =
"0.1.1"
DEFAULT_LOCALE =
[:ca].freeze

Class Method Summary collapse

Class Method Details

.days_in(start_time, end_time) ⇒ Object

Inclusive of start and end dates



51
52
53
# File 'lib/workdays/time_extensions.rb', line 51

def days_in(start_time, end_time)
  (end_time.to_date - start_time.to_date).to_i + 1
end

.workdays_in(start_time, end_time, locale = DEFAULT_LOCALE) ⇒ Object



42
43
44
45
46
47
48
# File 'lib/workdays/time_extensions.rb', line 42

def workdays_in(start_time, end_time, locale = DEFAULT_LOCALE)
  total_days = days_in(start_time, end_time)
  weekends   = weekends_in(start_time, end_time)
  holidays   = non_weekend_holidays_in(start_time, end_time, locale)

  total_days - weekends - holidays
end