Sha256: 8b96c1982e7a2960f583a7be00af2e92676b46f5b827ce769077fb385d78d454
Contents?: true
Size: 729 Bytes
Versions: 1
Compression:
Stored size: 729 Bytes
Contents
# -*- coding: utf-8 -*- require "date" # DateTime extensions class DateTime # @return [DateTime] a random date-time # # This is called by `Date.random` and `Time.random`. # # The default range is +/- 10000 days from now, # which is the same as `Date.random` and `Time.random`. # # @example # # DateTime.random # => "2014-12-31 12:59:59Z" # # @example with a range # # now = DateTime.now # range = (now - 10000)..(now + 10000) # DateTime.random(range) # # @param [Range<DateTime..DateTime>] A range of potential date-times, or nil for the default range. # def self.random(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_random-3.0.0 | lib/sixarm_ruby_date_time_random/date_time.rb |