| 1 |
|
| 2 |
#include <iostream> |
| 3 |
#include <chrono> |
| 4 |
#include <filesystem> |
| 5 |
|
| 6 |
using namespace std; |
| 7 |
using namespace chrono; |
| 8 |
using namespace filesystem; |
| 9 |
|
| 10 |
namespace fs = filesystem; |
| 11 |
|
| 12 |
auto local_time_point(time_point<system_clock> const &tp, char const *fmt) |
| 13 |
{ |
| 14 |
time_t secs = system_clock::to_time_t( tp ); |
| 15 |
return put_time(localtime(&secs), fmt); |
| 16 |
} |
| 17 |
|
| 18 |
int main() |
| 19 |
{ |
| 20 |
// system_clock::duration ds{ 24h }; |
| 21 |
// file_clock::duration df{ 1h }; |
| 22 |
|
| 23 |
file_clock::time_point p1 = fs::last_write_time("clock.cc"); |
| 24 |
file_clock::time_point p2 = fs::last_write_time("clock.cc"); |
| 25 |
|
| 26 |
cout << (p1 == p2) << '\n'; |
| 27 |
return 0; |
| 28 |
|
| 29 |
system_clock::from_time_t( |
| 30 |
system_clock::to_time_t( |
| 31 |
system_clock::from_time_t( |
| 32 |
12345 |
| 33 |
) |
| 34 |
) |
| 35 |
); |
| 36 |
|
| 37 |
std::time_t tm {time(0)}; |
| 38 |
std::cout << std::put_time(std::localtime(&tm), "%c") << '\n'; |
| 39 |
|
| 40 |
time_t secs = system_clock::to_time_t( system_clock::now() ); |
| 41 |
cout << put_time(std::localtime(&secs), "%c\n"); |
| 42 |
|
| 43 |
cout << local_time_point(system_clock{}.now(), "%c") << '\n'; |
| 44 |
|
| 45 |
// file_clock::to_time_t(file_clock::from_time_t(12345)); |
| 46 |
high_resolution_clock::to_time_t(high_resolution_clock::from_time_t(12345)); |
| 47 |
// steady_clock::to_time_t(steady_clock::from_time_t(12345)); |
| 48 |
|
| 49 |
// unsigned uval = system_clock::period::num; |
| 50 |
|
| 51 |
// file_clock::period rf; |
| 52 |
|
| 53 |
|
| 54 |
// system_clock::rep vs; |
| 55 |
// file_clock::rep vf; |
| 56 |
|
| 57 |
// system_clock::time_point st = system_clock{}.now(); |
| 58 |
|
| 59 |
file_clock::time_point ft; |
| 60 |
} |