On Wed, 26 Jan 2005 17:20:40 +0100, Wolfgang Fertsak wrote
If a date object is constructed from an invalid date(e.g. Feb 29th, 2005) and the values are specified in the constructor, an exception is thrown. If the object is constructed from a string representation with from_string(), no exception is thrown and the object has the next valid date (in this case Mar 1st, 2005).
Is this a bug or a feature?
That would be a bug. Note that the only invalid dates that will do this are non-leap year Feb 29 dates. That is, strDate("2005-02-30") will throw the exception. I'm afraid I can't check in a fix just at the moment, but it's a one line fix if you want to patch it: Change line 146 of boost/date_time/date_parsing.hpp from < return date_type(ymd); to
return date_type(ymd.year, ymd.month, ymd.day);
With this change you'll get the exception for the feb 29th's as well. Thanks for the report. Jeff