Sha256: 84901a399d36e1d3a4251982cc60701d75bc7bf79c3a1e49bfbe4e41800f61cf
Contents?: true
Size: 715 Bytes
Versions: 1
Compression:
Stored size: 715 Bytes
Contents
# -*- coding: utf-8 -*- require 'date' # DateTime extensions class DateTime # @return [DateTime] a random date-time # # This is called by `Date.rand` and `Time.rand`. # # The default range is +/- 10000 days from now, # which is the same as `Date.rand` and `Time.rand`. # # @example # # DateTime.rand # => "2014-12-31 12:59:59Z" # # @example with a range # # now = DateTime.now # range = (now - 10000)..(now + 10000) # DateTime.rand(range) # # @param [Range<DateTime..DateTime>] A range of potential date-times, or nil for the default range. # def self.rand(range = nil) range ? Kernel.rand(range) : (DateTime.now + Kernel.rand(-10000..10000)) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
sixarm_ruby_date_time_rand-2.0.0 | lib/sixarm_ruby_date_time_rand/date_time.rb |