Sha256: e0c75c85a3a4d777146318d6e9bb7d81e2fe919bef540ede59c8c74845dc7625
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.2 | lib/sixarm_ruby_date_time_rand/date_time.rb |