summaryrefslogtreecommitdiff
path: root/lib/custodian/parser.rb
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
commit0d33e88219c4ab5427114b79a19dc7033af3a772 (patch)
tree36e8f6c20c66aa67f7566e7a7e50897710742b0a /lib/custodian/parser.rb
parent4748e3630f2dc4eb7faab5682909f8832768495f (diff)
Use our utility class for time-period testing.
This fixes #4551, and closes #4551.
Diffstat (limited to 'lib/custodian/parser.rb')
-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