Updated Boost datetime Examples Translated (markdown)

Howard Hinnant
2017-07-07 20:18:39 -04:00
parent cd01e92ba4
commit 22edb7e88a

@@ -252,16 +252,16 @@ main()
```
<a name="Print_Holidays"></a>
### Print Holidays
```c++
#include "date.h"
#include <iostream>
#include <vector>
#include "date.h"
#include <iostream>
#include <vector>
std::vector<date:: sys_days>
generate_holidays(date::year y)
{
std::vector<date::sys_days>
generate_holidays(date::year y)
{
using namespace date;
std::vector< sys_days> holidays;
std::vector<sys_days> holidays;
holidays.push_back(y/jan/1); // Western New Year
holidays.push_back(y/jul/4); // US Independence Day
holidays.push_back(y/dec/25); // Christmas day
@@ -271,24 +271,24 @@ main()
holidays.push_back(y/nov/thu[4]); // Thanksgiving
std::sort(holidays.begin(), holidays.end());
return holidays;
}
}
int
main()
{
int
main()
{
using namespace date;
std::cout << "Enter Year: ";
int y;
std::cin >> y;
year y;
std::cin >> parse("%Y", y);
using namespace date;
//define a collection of holidays fixed by month and day
auto holidays = generate_holidays(year{y});
auto holidays = generate_holidays(y);
for (const auto& d : holidays)
std::cout << d << " [" << weekday(d) << "]\n";
std::cout << d << " [" << weekday{d} << "]\n";
std::cout << "Number Holidays: " << holidays.size() << '\n';
}
}
```
<a name="Print_Month"></a>
### Print Month