This is a question about invalid input, not invalid formatting. For example given the following code:
tm bar; foo >> get_time(&bar, \"%Y-
Since mktime tries to interpret also out-of-range values (i.e. for 2001-02-30 will be interpreted as 2001-03-01), you can do an mktime followed by a localtime, if you get different values back it means that the original ones were not valid.
mktime
localtime