Domanda

Strangely,

std::cout << boost::posix_time::from_iso_string("20120927T062299");// 99 seconds!

yields 2012-Sep-27 06:23:39, i.e. overflown seconds wrap into the next minute. Is it really an expected behaviour? If so, how can I force the functiion to fail in such circumstances?

È stato utile?

Soluzione

Different library implementors have different ideas of what should result in an error and of what severity.

The simple answer is, if the string comes from user input, check it yourself before providing it to any function expecting a properly-formatted string. This is generally a good idea anyway. In this case, a regular expression check would be fairly simple.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top