mirror of
https://github.com/HowardHinnant/date.git
synced 2025-08-04 21:24:26 +02:00
Updated Boost datetime Examples Translated (markdown)
@@ -28,7 +28,7 @@ look if ported to this library.
|
|||||||
<a name="Dates_as_Strings"></a>
|
<a name="Dates_as_Strings"></a>
|
||||||
### Dates as String
|
### Dates as String
|
||||||
```c++
|
```c++
|
||||||
#include "date.h"
|
#include "date/date.h"
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
@@ -59,8 +59,9 @@ main()
|
|||||||
|
|
||||||
// Let's send in month 25 by accident and create an exception
|
// Let's send in month 25 by accident and create an exception
|
||||||
in.str("20012509"); // 2001-??-09
|
in.str("20012509"); // 2001-??-09
|
||||||
|
in.clear();
|
||||||
in.exceptions(std::ios::failbit);
|
in.exceptions(std::ios::failbit);
|
||||||
cout << "An expected exception is next:\n";
|
cout << "An expected exception is next:" << endl;
|
||||||
in >> parse("%Y%m%d", d);
|
in >> parse("%Y%m%d", d);
|
||||||
cout << "oh oh, you shouldn't reach this line:\n";
|
cout << "oh oh, you shouldn't reach this line:\n";
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user