lib/fiscal_year.rb in fiscal_year-0.7.0 vs lib/fiscal_year.rb in fiscal_year-1.0.0

- old
+ new

@@ -51,14 +51,11 @@ def cross_year_months return [] if @config.start_month == 1 rindex = months.rindex(1).to_i - m = months.slice(rindex, months.length) - raise StandardError if m.nil? - - m + months.slice(rindex, months.length) || raise(StandardError) end # @return [Array(Array<Integer>, Array<Integer>)] the first half and the second half of the fiscal year. def halfs # @type self: singleton(FiscalYear) @@ -107,8 +104,25 @@ year = date.year month = date.month normalized_year = decrease_year_by_month(year, month) FiscalYear::Half.first_range_by(normalized_year).first..FiscalYear::Half.second_range_by(normalized_year).last + end + + # start by 0. + # + # @see passed_month_count_by_month + # @param date [Date] the date + # @return [Integer] the passed month count from the beginning of the fiscal year. + def passed_month_count_by(date) + passed_month_count_by_month(date.month) + end + + # start by 0. + # + # @param month [Integer] the month + # @return [Integer] the passed month count from the beginning of the fiscal year. + def passed_month_count_by_month(month) + months.find_index(month) || raise(StandardError) end end end