Updated Boost datetime Examples Translated (markdown)

Howard Hinnant
2017-07-07 20:14:51 -04:00
parent 8c3531f259
commit cd01e92ba4

@@ -221,36 +221,35 @@ main()
```
<a name="Date_Period_Calculations"></a>
### Date Period Calculations
```c++
#include "date.h"
#include <iostream>
#include "date.h"
#include <iostream>
#include <iterator>
int
main()
int
main()
{
using namespace date;
using date_period = std::pair<year_month_day, year_month_day>;
constexpr date_period ps[] =
{
using namespace date;
using date_period = std::pair<year_month_day, year_month_day>;
constexpr date_period ps[] =
{
{feb/ 2/2002, feb/ 4/2002}, // weekend of 2nd-3rd
{feb/ 9/2002, feb/11/2002},
{feb/16/2002, feb/18/2002},
{feb/23/2002, feb/25/2002},
{feb/12/2002, feb/13/2002} // a random holiday 2-12
};
std::cout << "Number Excluded Periods: " << sizeof(ps)/sizeof(ps[0]) << '\n';
auto d = feb/16/2002;
for (const auto& p : ps)
{
std::cout << p.first << " / " << p.second << '\n';
if (p.first <= d && d < p.second)
std::cout << "In Exclusion Period: "
<< d << " --> "
<< p.first << " / " << p.second << '\n';
}
{feb/ 2/2002, feb/ 4/2002}, // weekend of 2nd-3rd
{feb/ 9/2002, feb/11/2002},
{feb/16/2002, feb/18/2002},
{feb/23/2002, feb/25/2002},
{feb/12/2002, feb/13/2002} // a random holiday 2-12
};
std::cout << "Number Excluded Periods: " << sizeof(ps)/sizeof(ps[0]) << '\n';
auto d = feb/16/2002;
for (const auto& p : ps)
{
std::cout << p.first << " / " << p.second << '\n';
if (p.first <= d && d < p.second)
std::cout << "In Exclusion Period: "
<< d << " --> "
<< p.first << " / " << p.second << '\n';
}
}
```
<a name="Print_Holidays"></a>
### Print Holidays