mirror of
https://github.com/ditkrg/validates_timeliness.git
synced 2026-01-22 22:06:45 +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]
|
next if raw_value.is_nil? and options[:allow_nil]
|
||||||
|
|
||||||
begin
|
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
|
# checks if date is valid and enforces number of days in a month unlike Time
|
||||||
date = Date.new(*time_array[0..2])
|
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|
|
restriction_methods.each do |option, method|
|
||||||
if restriction = options[option]
|
if restriction = options[option]
|
||||||
restriction = restriction.to_time
|
restriction = restriction.to_time
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user