mirror of
https://github.com/HowardHinnant/date.git
synced 2025-08-05 21:54:27 +02:00
Updated Boost datetime Examples Translated (markdown)
@@ -342,7 +342,7 @@ main()
|
||||
```
|
||||
<a name="Time_Math"></a>
|
||||
### Time Math
|
||||
|
||||
```c++
|
||||
#include "date.h"
|
||||
#include <iostream>
|
||||
|
||||
@@ -352,17 +352,17 @@ main()
|
||||
using namespace std::chrono;
|
||||
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
|
||||
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';
|
||||
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>
|
||||
### Print Hours
|
||||
|
||||
|
Reference in New Issue
Block a user