Boost logo

Boost Users :

From: Jeff Garland (jeff_at_[hidden])
Date: 2005-01-26 22:37:43


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


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net