Hi, I have to store dates inside a DB, but unfortunately my date
representation can be a string like “2007” but also a normal date
string, like “2007-8-12” …
I want to use Date/DateTime objects because they are easy to
manipulate, but Date.parse can parse only the second format, not the
first (which is understandable …).
How can I solve this problem ? Storing something like 2007-0-0 or
2007-1-1 is ok for me, like in Date.new(2007).
I can check if the string contains ‘-’ and if not do something like
Date.new(string.to_i) but I don’t like this solution …
Chiacchiera con i tuoi amici in tempo reale!