diff options
| author | Steve Kemp <steve@steve.org.uk> | 2013-06-24 07:20:23 +0100 | 
|---|---|---|
| committer | Steve Kemp <steve@steve.org.uk> | 2013-06-24 07:20:23 +0100 | 
| commit | 0d33e88219c4ab5427114b79a19dc7033af3a772 (patch) | |
| tree | 36e8f6c20c66aa67f7566e7a7e50897710742b0a | |
| parent | 4748e3630f2dc4eb7faab5682909f8832768495f (diff) | |
  Use our utility class for time-period testing.
  This fixes #4551, and closes #4551.
| -rw-r--r-- | lib/custodian/parser.rb | 21 | 
1 files changed, 13 insertions, 8 deletions
| 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 @@ -266,16 +270,17 @@ 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 | 
