bug remains in posix_time io in 1.33RC2
Hi, In 1.33RC2, the string with wrong formatted date produce wrong date-time rather than error (vc-7_1): #include <iostream> #include <sstream> #include <string> #include <stdexcept> #include "boost/date_time/posix_time/posix_time.hpp" #include "boost/date_time/posix_time/posix_time_io.hpp" using namespace std; using namespace boost::posix_time; int main() { bool except_fg = false; string pts = "2002091"; istringstream iss(pts); iss.exceptions(ios::failbit); time_input_facet* tif = new time_input_facet; tif->set_iso_format(); iss.imbue(std::locale(std::locale::classic(), tif)); ptime pt; try { iss >> pt; } catch ( const exception& e ) { cout << "Exception reading 2002091: " << e.what() << endl; except_fg = true; } if ( !except_fg ) { cout << "Date-time from 2002091: " << pt << endl; except_fg = false; } pts = "20020913T17043"; iss.str(pts); try { iss >> pt; } catch ( const exception& e ) { cout << "Exception reading 20020913T17043: " << e.what() << endl; except_fg = true; } if ( !except_fg ) { cout << "Date-time from 20020913T17043: " << pt << endl; } return 0; } Output: Date-time from 2002091: 2002-Sep-11 00:00:00 Exception reading 20020913T17043: Parse failed. No match found for '' -- Serge
On Mon, 08 Aug 2005 18:45:11 +0400, Serge Skorokhodov wrote:
Hi,
In 1.33RC2, the string with wrong formatted date produce wrong date-time rather than error (vc-7_1):
...
Output:
Date-time from 2002091: 2002-Sep-11 00:00:00 Exception reading 20020913T17043: Parse failed. No match found for ''
We have a fix for this bug but, unfortunately, it wasn't done in time to make the 1.33 release. I believe the plan is to have it in cvs shortly after the 1.33 release is finalized. The fix will throw an exception in both of your try/catch blocks. However, I was unable to figure out how you got an "11" for the day-of-month. I always got "01". Bart
Bart wrote:
In 1.33RC2, the string with wrong formatted date produce wrong date-time rather than error (vc-7_1):
Output:
Date-time from 2002091: 2002-Sep-11 00:00:00 Exception reading 20020913T17043: Parse failed. No match found for ''
We have a fix for this bug but, unfortunately, it wasn't done in time to make the 1.33 release. I believe the plan is to have it in cvs shortly after the 1.33 release is finalized.
The fix will throw an exception in both of your try/catch blocks. However, I was unable to figure out how you got an "11" for the day-of-month. I always got "01".
Neither do I:)) I've used both RC2 and cvs builds. Actually, I can send you the executable;) As for the version when this bug is fixed, it's OK with me as I use cvs version anyway:) -- Serge
Hi, [...]
The fix will throw an exception in both of your try/catch blocks. However, I was unable to figure out how you got an "11" for the day-of-month. I always got "01".
I've rebuild today cvs update from scratch and compliled the code pasted from my message. It's still "11":( -- Serge
participants (2)
-
Bart
-
Serge Skorokhodov