mirror of
https://github.com/HowardHinnant/date.git
synced 2025-08-04 21:24:26 +02:00
Updated Boost datetime Examples Translated (markdown)
@@ -108,7 +108,7 @@ main()
|
|||||||
<a name="Days_Between_New_Years"></a>
|
<a name="Days_Between_New_Years"></a>
|
||||||
### Days Between New Years
|
### Days Between New Years
|
||||||
```c++
|
```c++
|
||||||
#include "tz.h"
|
#include "date/tz.h"
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
int
|
int
|
||||||
@@ -119,11 +119,11 @@ main()
|
|||||||
auto today = floor<days>(make_zoned(current_zone(),
|
auto today = floor<days>(make_zoned(current_zone(),
|
||||||
system_clock::now()).get_local_time());
|
system_clock::now()).get_local_time());
|
||||||
auto current_year = year_month_day{today}.year();
|
auto current_year = year_month_day{today}.year();
|
||||||
auto days_since_year_start = today - local_days(current_year/jan/1);
|
auto days_since_year_start = today - local_days{current_year/January/1};
|
||||||
std::cout << "Days since Jan 1: "
|
std::cout << "Days since Jan 1: "
|
||||||
<< days_since_year_start.count() << '\n';
|
<< days_since_year_start.count() << '\n';
|
||||||
auto days_until_year_start =
|
auto days_until_year_start =
|
||||||
local_days((current_year + years{1})/jan/1) - today;
|
local_days{(current_year + years{1})/January/1} - today;
|
||||||
std::cout << "Days until next Jan 1: "
|
std::cout << "Days until next Jan 1: "
|
||||||
<< days_until_year_start.count() << '\n';
|
<< days_until_year_start.count() << '\n';
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user