rails/rails — pull request #8722 by kwstannard (2013-01-03 16:12:25+00:00)
Title: Better error message for String#to_date

The main change of this PR is that passing in an invalid date will return "Argument Error: invalid date" instead of "NoMethodError: undefined method `div' for nil:NilClass".

I did this because the original error is unhelpful if you do not pass in a correct date. In the process I think this cleans up the code nicely.

Benchmark
https://gist.github.com/4440875