lib/schedulability/parser.rb in schedulability-0.2.0 vs lib/schedulability/parser.rb in schedulability-0.3.0
- old
+ new
@@ -238,15 +238,20 @@
hour = hour.to_i
if qualifier
raise Schedulability::RangeError, "invalid hour value: %p" % [ time_value ] if
hour > 12
- hour += 12 if qualifier == 'pm' && hour < 12
+
+ if qualifier == 'am' && hour == 12
+ hour = 0
+ elsif qualifier == 'pm' && hour < 12
+ hour += 12
+ end
+
else
raise Schedulability::RangeError, "invalid hour value: %p" % [ time_value ] if
- hour > 24
- hour = 24 if hour.zero?
+ hour < 0 || hour > 24
end
return hour
end
@@ -326,6 +331,5 @@
def strip_leading_zeros( val )
return val.sub( /\A0+(?!$)/, '' )
end
end # module Schedulability::Parser
-