Using utx::print_time
utx::print_time
Print one time point
Use utx::print_time to print c++ time point and use utx::print to print time duration:
#include <utxcpp/core.hpp> #include <chrono> int main() { // time point auto t1 = std::chrono::system_clock::now(); // time duration auto td = std::chrono::seconds(47); utx::print_time(t1); utx::print(td); }
utx::print_time supports std::chrono::system_clock, other c++ clocks might cause issues.
Output:
10:13:9.49 12.23 2022 47s
Print many time points
utx::print can print many time points with one call.
#include <utxcpp/core.hpp> #include <chrono> int main() { auto t1 = std::chrono::system_clock::now(); auto t2 = std::chrono::system_clock::time_point{}; t2 -= std::chrono::years(20); auto t3 = std::chrono::time_point<std::chrono::system_clock>{}; t3 += std::chrono::years(100); auto t4 = t3 + (t1-t2) + (t1-t3); utx::print_time(t1, t2, t3, t4); }
Output:
10:34:46.463 12.23 2022 3:36:0.0 1.1 1950 6:0:0.0 12.31 2069 17:33:32.927 12.14 2095
Comments
Display comments as Linear | Threaded