I have some code that simply accesses a datetime field so activerecord converts it to a Time object automatically when I read it:
@some_appointment.some_time
The problem is that sometimes the "some_time" datetime column has bad data. "0209-12-20" instead of "2009-12-20". This causes to Ruby to throw a "year too big to marshal" error just from accessing, and I can't seem to catch it as the error is not an exception. Given that there is some invalid data in my database, I want to try and make the time object myself by reading the datetime string and using Time.parse so I can catch an exception if the time cannot be parsed. How can I accomplish this? Is there a better way?