rescueArgumentError# if Date.new raises an exception on an invalid date
instantiate_time_object(name,set_values).to_date# we instantiate Time object and convert it back to a date thus using Time's logic in handling invalid dates
rescueArgumentError# if Date.new raises an exception on an invalid date
instantiate_time_object(set_values).to_date# we instantiate Time object and convert it back to a date thus using Time's logic in handling invalid dates
end
end
defread_other(klass)
max_position=extract_max_param
positions=(1..max_position)
validate_missing_parameters!(positions)
set_values=values.values_at(*positions)
klass.new(*set_values)
end
# Checks whether some blank date parameter exists. Note that this is different
# than the validate_missing_parameters! method, since it just checks for blank
# positions instead of missing ones, and does not raise in case one blank position
# exists. The caller is responsible to handle the case of this returning true.
defblank_date_parameter?
(1..3).any?{|position|values[position].blank?}
end
# If some position is not provided, it errors out a missing parameter exception.