Class: TimeToday
- Inherits:
-
Object
- Object
- TimeToday
- Defined in:
- lib/timetoday.rb
Class Method Summary collapse
Class Method Details
.any ⇒ Object
11 12 13 14 15 16 17 18 19 |
# File 'lib/timetoday.rb', line 11 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
21 22 23 |
# File 'lib/timetoday.rb', line 21 def self.between(s1,s2) rand Time.parse(s1)..Time.parse(s2) end |
.future ⇒ Object
25 26 27 28 29 |
# File 'lib/timetoday.rb', line 25 def self.future() t = Time.now time_remaining = ((Time.now.to_date + 1).to_time - 1) - t t + rand(time_remaining) end |
.within(duration) ⇒ Object
31 32 33 |
# File 'lib/timetoday.rb', line 31 def self.within(duration) Time.now + rand(ChronicDuration.parse(duration)) end |