Sha256: 739deb195c0656afaf00b7339b9b8d1f796a422a00b6625a6fd55e420158f9e8

Contents?: true

Size: 693 Bytes

Versions: 1

Compression:

Stored size: 693 Bytes

Contents

class Date
  include ErrorHelper

  def self.build_date_array(start_date, end_date)
    start_date = start_date.to_date
    end_date   =  end_date.to_date

    raise_start_date_before_end_date if (start_date > end_date)

    date_array = []
    processable_date = start_date.dup
    while processable_date <= end_date
      date_array << processable_date
      processable_date = processable_date.tomorrow
    end

    return date_array
  end

  def build_date_array(date)
    date = date.to_date

    if self < date
      start_date = self
      end_date = date
    else
      start_date = date
      end_date = self
    end

    return Date.build_date_array(start_date, end_date)
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
creative_rails_utilities-0.1.2 lib/creative_rails_utilities/date.rb