Sha256: 8390be618b9fc56a27cf8ea32ceef7c3225daada5f0a3026f212409c0e2efe75

Contents?: true

Size: 701 Bytes

Versions: 2

Compression:

Stored size: 701 Bytes

Contents

module ByStar
  module Calculations
    include Count
    include Sum
    
    private
      def work_out_month(time, options = {})
        year = options[:year] ||= Time.zone.now.year
        # Work out what actual month is.
        month = if time.is_a?(Numeric) && (1..12).include?(time)
          time
        elsif valid_time_or_date?(time)
          year = time.year
          time.month
        elsif time.is_a?(String) && Date::MONTHNAMES.include?(time)
          Date::MONTHNAMES.index(time)
        else
          raise ParseError, "Value is not an integer (between 1 and 12), time object or string (make sure you typed the name right)."
        end
        [year, month]
      end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
by_star-0.3.1 lib/calculations.rb
by_star-0.3.0 lib/calculations.rb