Class: Date

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

Instance Method Summary collapse

Instance Method Details

#beginning_of_fiscal_yearObject Also known as: at_beginning_of_fiscal_year

Like beginning_of_year, but for Fiscal Years. Date.new(2015,10,1).beginning_of_fiscal_year => 2015-07-01



12
13
14
# File 'lib/duffy/date.rb', line 12

def beginning_of_fiscal_year
  Date.new(fiscal_year - 1, Duffy.configuration.fiscal_month, Duffy.configuration.fiscal_day)
end

#end_of_fiscal_yearObject Also known as: at_end_of_fiscal_year

Like end_of_year, but for Fiscal Years Date.new(2015,10,1).end_of_fiscal_year => 2016-06-30



19
20
21
# File 'lib/duffy/date.rb', line 19

def end_of_fiscal_year
  Date.new(fiscal_year, Duffy.configuration.fiscal_month, Duffy.configuration.fiscal_day).prev_day
end

#fiscal_yearObject

Return the fiscal year for a given date. See config to set the start of your fiscal year. Example: Date.new(2015,10,1).fiscal_year => 2016



6
7
8
# File 'lib/duffy/date.rb', line 6

def fiscal_year
  (self < Date.new(year, Duffy.configuration.fiscal_month, Duffy.configuration.fiscal_day)) ? year : year + 1
end