is there any function to check if a given date is valid or not? I don\'t want to write anything from scratch.
e.g. 32/10/2012 is not valid and 10/10/2010 is valid
If your string is always in that format the easiest thing to do would be to split the string into its three components, populate a tm
structure and pass it to mktime()
. If it returns -1 then it's not a valid date.
You could also use Boost.Date_Time to parse it:
string inp("10/10/2010");
string format("%d/%m/%Y");
date d;
d = parser.parse_date(inp, format, svp);