From b3a44884b7060add75b68722e2880a4e8e972405 Mon Sep 17 00:00:00 2001 From: Howard Hinnant Date: Fri, 7 Jul 2017 21:14:45 -0400 Subject: [PATCH] Updated Boost datetime Examples Translated (markdown) --- Boost-datetime-Examples-Translated.md | 38 +++++++++++++-------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/Boost-datetime-Examples-Translated.md b/Boost-datetime-Examples-Translated.md index 79929cf..7299d79 100644 --- a/Boost-datetime-Examples-Translated.md +++ b/Boost-datetime-Examples-Translated.md @@ -342,27 +342,27 @@ main() ``` ### Time Math +```c++ +#include "date.h" +#include - #include "date.h" - #include - - int - main() - { - using namespace std::chrono; - using namespace date; - - auto d = sys_days(2002_y/feb/1); // an arbitrary date; - // construct a time by adding up some durations durations - auto t1 = d + 5h + 4min + 2s + 1ms; - // construct a new time by subtracting some times - auto t2 = t1 - 5h - 4min - 2s - 1ms; - // construct a duration by taking the difference between times - auto td = t2 - t1; - std::cout << t2 << " - " << t1 << " = " << make_time(td) << '\n'; - // 2002-02-01 00:00:00.000 - 2002-02-01 05:04:02.001 = -05:04:02.001 - } +int +main() +{ + using namespace std::chrono; + using namespace date; + auto d = sys_days{2002_y/feb/1}; // an arbitrary date; + // construct a time by adding up some durations durations + auto t1 = d + 5h + 4min + 2s + 1ms; + // construct a new time by subtracting some times + auto t2 = t1 - 5h - 4min - 2s - 1ms; + // construct a duration by taking the difference between times + auto td = t2 - t1; + std::cout << t2 << " - " << t1 << " = " << format("%T\n", td); + // 2002-02-01 00:00:00.000 - 2002-02-01 05:04:02.001 = -05:04:02.001 +} +``` ### Print Hours