Module: Birling::Support

Extended by:
Support
Included in:
Support
Defined in:
lib/birling/support.rb

Instance Method Summary collapse

Instance Method Details

#next_day(time, time_source = nil) ⇒ Object

Computes the beginning of the next day.



5
6
7
8
9
10
11
12
13
14
# File 'lib/birling/support.rb', line 5

def next_day(time, time_source = nil)
  (time_source || Time).local(
    time.year,
    time.month,
    time.day,
    23,
    59,
    59
  ) + 1
end

#next_hour(time, time_source = nil) ⇒ Object

Computes the beginning of the next hour.



17
18
19
20
21
# File 'lib/birling/support.rb', line 17

def next_hour(time, time_source = nil)
  seconds_left = time.to_i % 3600
  
  time + (seconds_left > 0 ? seconds_left : 3600)
end