Class: TimeToday
- Inherits:
-
Object
- Object
- TimeToday
- Defined in:
- lib/timetoday.rb
Class Method Summary collapse
Class Method Details
.any ⇒ Object
10 11 12 13 14 15 16 17 18 |
# File 'lib/timetoday.rb', line 10 def self.any() #seconds_in_day = (DateTime.now + 1).to_time - DateTime.now.to_time seconds_in_day = 86399.999461942 # result from above any_time = Time.at rand(seconds_in_day) day, mon, year = Time.now.to_a.values_at 3,4,5 s, min, hr = any_time.to_a.values_at 0,1,2 Time.new(year, mon, day, hr, min, s) end |
.between(s1, s2) ⇒ Object
20 21 22 |
# File 'lib/timetoday.rb', line 20 def self.between(s1,s2) rand Time.parse(s1)..Time.parse(s2) end |
.future ⇒ Object
24 25 26 27 28 |
# File 'lib/timetoday.rb', line 24 def self.future() t = Time.now time_remaining = ((Time.now.to_date + 1).to_time - 1) - t t + rand(time_remaining) end |