Actually better still would be `val.try(:to_time)`. No need for type checks or rescuing.

Also a small stylistic point: we prefer not to abbreviate our variables. `value` and `attribute` over `val` and `attr`.