summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteve Kemp <steve@steve.org.uk>2013-06-24 07:20:23 +0100
committerSteve Kemp <steve@steve.org.uk>2013-06-24 07:20:23 +0100
commitacf66f27d63ac31f8ca3b7f1833c1ff64cb566dc (patch)
treefe8fd5ab901a930a892eeddc7dfe71a826fa7aed
parent34d910212a93737367ff29d325afcd3f33f29cba (diff)
Use our utility class for time-period testing.
This fixes #4551, and closes #4551.
-rw-r--r--lib/custodian/parser.rb21
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