mirror of
https://github.com/HowardHinnant/date.git
synced 2025-08-06 14:14:27 +02:00
Updated Boost datetime Examples Translated (markdown)
@@ -221,36 +221,35 @@ main()
|
|||||||
```
|
```
|
||||||
<a name="Date_Period_Calculations"></a>
|
<a name="Date_Period_Calculations"></a>
|
||||||
### Date Period Calculations
|
### Date Period Calculations
|
||||||
|
```c++
|
||||||
|
#include "date.h"
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
#include "date.h"
|
int
|
||||||
#include <iostream>
|
main()
|
||||||
#include <iterator>
|
{
|
||||||
|
using namespace date;
|
||||||
int
|
using date_period = std::pair<year_month_day, year_month_day>;
|
||||||
main()
|
constexpr date_period ps[] =
|
||||||
{
|
{
|
||||||
using namespace date;
|
{feb/ 2/2002, feb/ 4/2002}, // weekend of 2nd-3rd
|
||||||
using date_period = std::pair<year_month_day, year_month_day>;
|
{feb/ 9/2002, feb/11/2002},
|
||||||
constexpr date_period ps[] =
|
{feb/16/2002, feb/18/2002},
|
||||||
{
|
{feb/23/2002, feb/25/2002},
|
||||||
{feb/ 2/2002, feb/ 4/2002}, // weekend of 2nd-3rd
|
{feb/12/2002, feb/13/2002} // a random holiday 2-12
|
||||||
{feb/ 9/2002, feb/11/2002},
|
};
|
||||||
{feb/16/2002, feb/18/2002},
|
std::cout << "Number Excluded Periods: " << sizeof(ps)/sizeof(ps[0]) << '\n';
|
||||||
{feb/23/2002, feb/25/2002},
|
auto d = feb/16/2002;
|
||||||
{feb/12/2002, feb/13/2002} // a random holiday 2-12
|
for (const auto& p : ps)
|
||||||
};
|
{
|
||||||
std::cout << "Number Excluded Periods: " << sizeof(ps)/sizeof(ps[0]) << '\n';
|
std::cout << p.first << " / " << p.second << '\n';
|
||||||
auto d = feb/16/2002;
|
if (p.first <= d && d < p.second)
|
||||||
for (const auto& p : ps)
|
std::cout << "In Exclusion Period: "
|
||||||
{
|
<< d << " --> "
|
||||||
std::cout << p.first << " / " << p.second << '\n';
|
<< 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>
|
<a name="Print_Holidays"></a>
|
||||||
### Print Holidays
|
### Print Holidays
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user