Module: WhiteHare::Monthly
- Defined in:
- lib/white_hare/monthly.rb
Class Method Summary collapse
- .beginning_of(year, month, closing_date: nil) ⇒ Object
- .end_of(year, month, closing_date: nil) ⇒ Object
- .next_month(year, month, day) ⇒ Object
- .prev_month(year, month, day) ⇒ Object
- .term(year, month, closing_date: nil) ⇒ Object
Class Method Details
.beginning_of(year, month, closing_date: nil) ⇒ Object
13 14 15 16 |
# File 'lib/white_hare/monthly.rb', line 13 def self.beginning_of(year, month, closing_date: nil) return Date.new(year, month, 1) if closing_date.nil? prev_month(year, month, closing_date) + 1 end |
.end_of(year, month, closing_date: nil) ⇒ Object
18 19 20 21 |
# File 'lib/white_hare/monthly.rb', line 18 def self.end_of(year, month, closing_date: nil) return Date.new(year, month, closing_date) unless closing_date.nil? next_month(year, month, 1) - 1 end |
.next_month(year, month, day) ⇒ Object
5 6 7 |
# File 'lib/white_hare/monthly.rb', line 5 def self.next_month(year, month, day) Date.new(year, month, day) >> 1 end |
.prev_month(year, month, day) ⇒ Object
9 10 11 |
# File 'lib/white_hare/monthly.rb', line 9 def self.prev_month(year, month, day) Date.new(year, month, day) << 1 end |
.term(year, month, closing_date: nil) ⇒ Object
23 24 25 26 27 |
# File 'lib/white_hare/monthly.rb', line 23 def self.term(year, month, closing_date: nil) first = beginning_of(year, month, closing_date: closing_date) last = end_of(year, month, closing_date: closing_date) first..last end |