check for Time object before validating

This commit is contained in:
Adam Meehan 2008-05-02 17:14:48 +10:00
parent 591ea3126b
commit dff7900c4a

View File

@ -20,13 +20,17 @@ 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)
# checks if time is valid as it will accept bad date values
time = Time.mktime(*time_array)
end
restriction_methods.each do |option, method|
if restriction = options[option]