mirror of
https://github.com/ditkrg/validates_timeliness.git
synced 2026-01-23 06:16:44 +00:00
check for Time object before validating
This commit is contained in:
parent
591ea3126b
commit
dff7900c4a
@ -20,14 +20,18 @@ module ValidatesTimeliness
|
||||
next if raw_value.is_nil? and options[:allow_nil]
|
||||
|
||||
begin
|
||||
time_array = ParseDate.parsedate(raw_value)
|
||||
if raw_value.acts_like?(:time)
|
||||
time = raw_value
|
||||
else
|
||||
time_array = ParseDate.parsedate(raw_value)
|
||||
|
||||
# checks if date is valid and enforces number of days in a month unlike Time
|
||||
date = Date.new(*time_array[0..2])
|
||||
# checks if date is valid and enforces number of days in a month unlike Time
|
||||
date = Date.new(*time_array[0..2])
|
||||
|
||||
# checks if time is valid as it will accept bad date values
|
||||
time = Time.mktime(*time_array)
|
||||
end
|
||||
|
||||
# checks if time is valid as it will accept bad date values
|
||||
time = Time.mktime(*time_array)
|
||||
|
||||
restriction_methods.each do |option, method|
|
||||
if restriction = options[option]
|
||||
restriction = restriction.to_time
|
||||
|
||||
Loading…
Reference in New Issue
Block a user