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



2
3
4
5
6
7
8
9
10
11
# File 'lib/birling/support.rb', line 2

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



13
14
15
16
17
# File 'lib/birling/support.rb', line 13

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