Updated Boost datetime Examples Translated (markdown)

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

@@ -342,27 +342,27 @@ main()
``` ```
<a name="Time_Math"></a> <a name="Time_Math"></a>
### Time Math ### Time Math
```c++
#include "date.h"
#include <iostream>
#include "date.h" int
#include <iostream> main()
{
int using namespace std::chrono;
main() using namespace date;
{
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
}
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
}
```
<a name="Print_Hours"></a> <a name="Print_Hours"></a>
### Print Hours ### Print Hours