mirror of
https://github.com/ditkrg/validates_timeliness.git
synced 2026-01-25 15:22:58 +00:00
don't allow 0 or > 12 for meridian am hour
This commit is contained in:
@@ -243,6 +243,8 @@ module ValidatesTimeliness
|
||||
values[0..2] = ValidatesTimeliness.dummy_date_for_time_type if type == :time
|
||||
return values
|
||||
end
|
||||
rescue
|
||||
nil
|
||||
end
|
||||
|
||||
# Delete formats of specified type. Error raised if format not found.
|
||||
@@ -289,6 +291,7 @@ module ValidatesTimeliness
|
||||
hour = hour.to_i
|
||||
return hour if meridian.nil?
|
||||
if meridian.delete('.').downcase == 'am'
|
||||
raise if hour == 0 || hour > 12
|
||||
hour == 12 ? 0 : hour
|
||||
else
|
||||
hour == 12 ? hour : hour + 12
|
||||
|
||||
Reference in New Issue
Block a user