diff --git a/Boost-datetime-Examples-Translated.md b/Boost-datetime-Examples-Translated.md index 3520792..79929cf 100644 --- a/Boost-datetime-Examples-Translated.md +++ b/Boost-datetime-Examples-Translated.md @@ -322,26 +322,24 @@ main() ``` ### Month Adding +```c++ +#include "tz.h" +#include - #include "date.h" - #include "tz.h" - #include - - int - main() - { - using namespace std::chrono; - using namespace date; - auto zone = current_zone(); - auto d = year_month_day{floor( - zone->to_local(system_clock::now()))}; - auto d2 = d + months{1}; - if (!d2.ok()) - d2 = d2.year()/d2.month()/last; // boost snaps to last - std::cout << "Today is: " << d << ".\n" - << "One month from today will be: " << d2 << '\n'; - } - +int +main() +{ + using namespace std::chrono; + using namespace date; + auto d = year_month_day{floor(make_zoned(current_zone(), + system_clock::now()).get_local_time())}; + auto d2 = d + months{1}; + if (!d2.ok()) + d2 = d2.year()/d2.month()/last; // boost snaps to last + std::cout << "Today is: " << d << ".\n" + << "One month from today will be: " << d2 << '\n'; +} +``` ### Time Math