lib/sensu/utilities.rb
# Determine if the current time falls within a time window. The
# provided condition must have a `:begin` and `:end` time, eg.
# "11:30:00 PM", or `false` will be returned.
#
# @param condition [Hash]
# @option condition [String] :begin time.
# @option condition [String] :end time.
# @return [TrueClass, FalseClass]
Determine if the current time falls within a time window. The
provided condition must have a `:begin` and `:end` time, eg.
Determine if the current time falls within a time window . The provided condition must have a ` : begin ` and ` : end ` time eg .
def in_time_window?(condition)
      if condition.has_key?(:begin) && condition.has_key?(:end)
        begin_time = Time.parse(condition[:begin])
        end_time = Time.parse(condition[:end])
        if end_time < begin_time
          if Time.now < end_time
            begin_time = Time.parse(*begin_time.strftime("%Y-%m-%d 00:00:00.#{Array.new(NANOSECOND_RESOLUTION, 0).join} %:z"))
          else
            end_time = Time.parse(*end_time.strftime("%Y-%m-%d 23:59:59.#{Array.new(NANOSECOND_RESOLUTION, 9).join} %:z"))
          end
        end
        Time.now >= begin_time && Time.now <= end_time
      else
        false
      end
    end
def in_time_window? ( condition ) if condition . has_key? ( :begin ) && condition . has_key? ( :end ) begin_time = Time . parse ( condition [ :begin ] ) end_time = Time . parse ( condition [ :end ] ) if end_time < begin_time if Time . now < end_time begin_time = Time . parse ( * begin_time . strftime ( "%Y-%m-%d 00:00:00.#{Array.new(NANOSECOND_RESOLUTION, 0).join} %:z" ) ) else end_time = Time . parse ( * end_time . strftime ( "%Y-%m-%d 23:59:59.#{Array.new(NANOSECOND_RESOLUTION, 9).join} %:z" ) ) end end Time . now >= begin_time && Time . now <= end_time else false end end
Determine if the current time falls within a time window.
Determine if the current time falls within a time window .
None
TrueClass, FalseClass
condition
None
None