Module: BankWorkingDay
- Defined in:
- lib/bank_working_day.rb,
lib/bank_working_day/version.rb,
lib/bank_working_day/holidays.rb
Defined Under Namespace
Classes: Holiday, Holidays
Constant Summary
collapse
- VERSION =
"0.1.4"
Class Method Summary
collapse
Class Method Details
.deduction_date(year:, month:, day: 27) ⇒ Object
32
33
34
35
36
37
38
39
40
41
|
# File 'lib/bank_working_day.rb', line 32
def self.deduction_date(year: , month: , day: 27)
raise InvalidArgumentError if year.to_i.zero? || month.to_i.zero?
date = Date.new(year.to_i, month.to_i, day.to_i)
while holiday?(date)
date += 1
end
date
end
|
.end_of_month_without_holiday(date) ⇒ Object
7
8
9
10
11
12
|
# File 'lib/bank_working_day.rb', line 7
def self.end_of_month_without_holiday(date)
date.end_of_month.day.downto(1) do |last_day|
last_day = Date.new(date.year, date.month, last_day)
return last_day unless holidays.holiday?(last_day)
end
end
|
.holiday?(date) ⇒ Boolean
43
44
45
|
# File 'lib/bank_working_day.rb', line 43
def self.holiday?(date)
holidays.holiday?(date)
end
|
.working_day_after(date:, offset:) ⇒ Object
23
24
25
26
27
28
29
30
|
# File 'lib/bank_working_day.rb', line 23
def self.working_day_after(date: , offset: )
offset.times do |i|
date += 1
date += 1 while holiday?(date)
end
date
end
|
.working_day_before(date:, offset:) ⇒ Object
14
15
16
17
18
19
20
21
|
# File 'lib/bank_working_day.rb', line 14
def self.working_day_before(date: , offset: )
offset.times do |i|
date -= 1
date -= 1 while holiday?(date)
end
date
end
|