mirror of
https://github.com/HowardHinnant/date.git
synced 2025-08-05 13:44:26 +02:00
Updated Boost datetime Examples Translated (markdown)
@@ -139,14 +139,13 @@ look if ported to this library.
|
||||
{
|
||||
using namespace std::chrono;
|
||||
using namespace date;
|
||||
auto today = floor<days>(current_zone()->
|
||||
to_local(system_clock::now()).first);
|
||||
auto today = floor<days>(current_zone()->to_local(system_clock::now()));
|
||||
auto current_year = year_month_day{today}.year();
|
||||
auto days_since_year_start = today - sys_days(current_year/jan/1);
|
||||
auto days_since_year_start = today - local_days(current_year/jan/1);
|
||||
std::cout << "Days since Jan 1: "
|
||||
<< days_since_year_start.count() << '\n';
|
||||
auto days_until_year_start =
|
||||
sys_days((current_year + years{1})/jan/1) - today;
|
||||
local_days((current_year + years{1})/jan/1) - today;
|
||||
std::cout << "Days until next Jan 1: "
|
||||
<< days_until_year_start.count() << '\n';
|
||||
}
|
||||
|
Reference in New Issue
Block a user