Updated Boost datetime Examples Translated (markdown)

Howard Hinnant
2017-07-07 17:49:03 -04:00
parent 1c120715f3
commit f71f8ed5fb

@@ -106,27 +106,27 @@ main()
``` ```
<a name="Days_Between_New_Years"></a> <a name="Days_Between_New_Years"></a>
### Days Between New Years ### Days Between New Years
```c++
#include "tz.h"
#include <iostream>
#include "date.h" int
#include "tz.h" main()
#include <iostream> {
using namespace std::chrono;
int using namespace date;
main() auto today = floor<days>(make_zoned(current_zone(),
{ system_clock::now()).get_local_time());
using namespace std::chrono; auto current_year = year_month_day{today}.year();
using namespace date; auto days_since_year_start = today - local_days(current_year/jan/1);
auto today = floor<days>(current_zone()->to_local(system_clock::now())); std::cout << "Days since Jan 1: "
auto current_year = year_month_day{today}.year(); << days_since_year_start.count() << '\n';
auto days_since_year_start = today - local_days(current_year/jan/1); auto days_until_year_start =
std::cout << "Days since Jan 1: " local_days((current_year + years{1})/jan/1) - today;
<< days_since_year_start.count() << '\n'; std::cout << "Days until next Jan 1: "
auto days_until_year_start = << days_until_year_start.count() << '\n';
local_days((current_year + years{1})/jan/1) - today; }
std::cout << "Days until next Jan 1: " ```
<< days_until_year_start.count() << '\n';
}
<a name="Last_Day_of_the_Months"></a> <a name="Last_Day_of_the_Months"></a>
### Last Day of the Months ### Last Day of the Months