From 0d33e88219c4ab5427114b79a19dc7033af3a772 Mon Sep 17 00:00:00 2001 From: Steve Kemp Date: Mon, 24 Jun 2013 07:20:23 +0100 Subject: Use our utility class for time-period testing. This fixes #4551, and closes #4551. --- lib/custodian/parser.rb | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'lib/custodian/parser.rb') diff --git a/lib/custodian/parser.rb b/lib/custodian/parser.rb index a9afcd9..6b71541 100644 --- a/lib/custodian/parser.rb +++ b/lib/custodian/parser.rb @@ -5,10 +5,10 @@ require 'uri' # -# The list of all our protocol tests. +# The modules we've implemented # require 'custodian/protocoltests' - +require 'custodian/util/timespan' @@ -257,6 +257,10 @@ module Custodian # Look for a time period. # if ( line =~ /between\s+([0-9]+)-([0-9]+)/i ) + + # + # The starting/ending hours. + # p_start = $1.dup.to_i p_end = $2.dup.to_i @@ -265,17 +269,18 @@ module Custodian # hour = Time.now.hour + # + # Does the hour match the period? + # + inside = Custodian::Util::TimeSpan.inside?( p_start, p_end, hour ) + # # Should we exclude the test? # if ( line =~ /except\s+between/i ) - if ( hour > p_start && hour < p_end ) - return nil - end + return nil if ( inside ) else - if ( hour < p_start || hour > p_end ) - return nil - end + return nil if ( ! inside ) end end -- cgit v1.2.1