Sha256: 0cbc5a5a62626c9aa9ed86c53546d25b01d46a201080fa827bcbe7edbb7c9eab
Contents?: true
Size: 937 Bytes
Versions: 11
Compression:
Stored size: 937 Bytes
Contents
class Time unless self.public_instance_methods.include?("to_date") if self.private_instance_methods.include?("to_date") || self.protected_instance_methods.include?("to_date") public :to_date else def to_date require 'date' # just in case jd = Date.__send__(:civil_to_jd, year, mon, mday, Date::ITALY) Date.new!(Date.__send__(:jd_to_ajd, jd, 0, 0), 0, Date::ITALY) end end end unless self.public_instance_methods.include?("to_datetime") if self.private_instance_methods.include?("to_datetime") || self.protected_instance_methods.include?("to_datetime") public :to_datetime else def to_datetime raise NoMethodError.new("to_datetime") end end end # Generates a random Time between the start time and the end time. def self.random(start_time, end_time = Time.now) start_time + (rand(end_time - start_time).to_i) end end
Version data entries
11 entries across 11 versions & 1 rubygems