re: to_yaml fails for DateTime objects

I found this bug on Lighthouse with no patch and wrote a fix with necessary tests. The patch is available on the ticket page ( https://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/3511-to_yaml-fails-for-datetime-objects )

This patch applies to 2-3-stable branch. I'll soon upload a patch for master as well.

In the same ticket, I also attached a patch file for the master branch.