Updated Boost datetime Examples Translated (markdown)

Howard Hinnant
2017-07-07 21:14:45 -04:00
parent 70d5caa240
commit b3a44884b7

@@ -342,7 +342,7 @@ main()
``` ```
<a name="Time_Math"></a> <a name="Time_Math"></a>
### Time Math ### Time Math
```c++
#include "date.h" #include "date.h"
#include <iostream> #include <iostream>
@@ -352,17 +352,17 @@ main()
using namespace std::chrono; using namespace std::chrono;
using namespace date; using namespace date;
auto d = sys_days(2002_y/feb/1); // an arbitrary date; auto d = sys_days{2002_y/feb/1}; // an arbitrary date;
// construct a time by adding up some durations durations // construct a time by adding up some durations durations
auto t1 = d + 5h + 4min + 2s + 1ms; auto t1 = d + 5h + 4min + 2s + 1ms;
// construct a new time by subtracting some times // construct a new time by subtracting some times
auto t2 = t1 - 5h - 4min - 2s - 1ms; auto t2 = t1 - 5h - 4min - 2s - 1ms;
// construct a duration by taking the difference between times // construct a duration by taking the difference between times
auto td = t2 - t1; auto td = t2 - t1;
std::cout << t2 << " - " << t1 << " = " << make_time(td) << '\n'; 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 // 2002-02-01 00:00:00.000 - 2002-02-01 05:04:02.001 = -05:04:02.001
} }
```
<a name="Print_Hours"></a> <a name="Print_Hours"></a>
### Print Hours ### Print Hours