Sha256: 69249b3f658f6cd89e7ee6d59322c288a4955f06d593b5aec8be5f53510d53f1

Contents?: true

Size: 527 Bytes

Versions: 5

Compression:

Stored size: 527 Bytes

Contents

module Birling::Support
  # == Module + Mixin Methods ===============================================

  # Computes the beginning of the next day.
  def next_day(time, time_source = nil)
    (time_source || Time).local(
      time.year,
      time.month,
      time.day,
      23,
      59,
      59
    ) + 1
  end
  
  # Computes the beginning of the next hour.
  def next_hour(time, time_source = nil)
    seconds_left = time.to_i % 3600
    
    time + (seconds_left > 0 ? seconds_left : 3600)
  end
    
  extend self
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
birling-0.3.1 lib/birling/support.rb
birling-0.3.0 lib/birling/support.rb
birling-0.2.2 lib/birling/support.rb
birling-0.2.1 lib/birling/support.rb
birling-0.2.0 lib/birling/support.rb