mirror of
https://github.com/HowardHinnant/date.git
synced 2025-08-06 14:14:27 +02:00
Updated Boost datetime Examples Translated (markdown)
@@ -140,12 +140,16 @@ look if ported to this library.
|
|||||||
{
|
{
|
||||||
using namespace std::chrono;
|
using namespace std::chrono;
|
||||||
using namespace date;
|
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()).first);
|
||||||
auto current_year = year_month_day{today}.year();
|
auto current_year = year_month_day{today}.year();
|
||||||
auto days_since_year_start = today - day_point(current_year/jan/1);
|
auto days_since_year_start = today - day_point(current_year/jan/1);
|
||||||
std::cout << "Days since Jan 1: " << days_since_year_start.count() << '\n';
|
std::cout << "Days since Jan 1: "
|
||||||
auto days_until_year_start = day_point((current_year + years{1})/jan/1) - today;
|
<< days_since_year_start.count() << '\n';
|
||||||
std::cout << "Days until next Jan 1: " << days_until_year_start.count() << '\n';
|
auto days_until_year_start =
|
||||||
|
day_point((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>
|
||||||
|
Reference in New Issue
Block a user