lib/validates_timeliness/validator.rb in adzap-validates_timeliness-2.2.0 vs lib/validates_timeliness/validator.rb in adzap-validates_timeliness-2.2.1

- old
+ new

@@ -195,15 +195,15 @@ if value.is_a?(Array) value.map {|v| type_cast_value(v, type, ignore_usec) } else value = case type when :time - value.to_dummy_time + dummy_time(value) when :date value.to_date when :datetime - if value.is_a?(DateTime) || value.is_a?(Time) + if value.is_a?(Time) || value.is_a?(DateTime) value.to_time else value.to_time(ValidatesTimeliness.default_timezone) end else @@ -213,9 +213,19 @@ ValidatesTimeliness::Parser.make_time(Array(value).reverse[4..9]) else value end end + end + + def dummy_time(value) + if value.is_a?(Time) || value.is_a?(DateTime) + time = [value.hour, value.min, value.sec] + else + time = [0,0,0] + end + dummy_date = ValidatesTimeliness::Formats.dummy_date_for_time_type + Time.send(ValidatesTimeliness.default_timezone, *(dummy_date + time)) end end end