Sha256: dec9f650043a5eacf9b300b55d9cc3d45435a6d7349b04430a23092f4c1e599d

Contents?: true

Size: 623 Bytes

Versions: 1

Compression:

Stored size: 623 Bytes

Contents

# -*- coding: utf-8 -*-

require "date"

# Date extensions

class Date

  # @return [Date] a random daate
  #
  # This calls `DateTime#random`.
  #
  # The default range is +/- 10000 days from now.
  # which is the same as `DateTime.random` and `Time.random`.
  #
  # @example
  #
  #   Date.random
  #   => "2014-12-31" 
  #
  # @example with a range
  #
  #   today = Date.today
  #   range = (today - 10000)..(today + 10000)
  #   Date.random(range)
  #
  # @param [Range<Date..Dateb>] A range of potential dates, or nil for the default.
  #
  def self.random(range = nil)
    DateTime.random(range).to_date
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
sixarm_ruby_date_time_random-3.0.0 lib/sixarm_ruby_date_time_random/date.rb