Loading...
Searching...
No Matches
timestamp.hpp
Go to the documentation of this file.
1
2#pragma once
3#include <chrono>
4#include <ctime>
5
6namespace terra::util {
7
8/// @brief Get the current timestamp as a string.
9/// @return Timestamp string.
10inline std::string current_timestamp()
11{
12 using namespace std::chrono;
13 const auto now = system_clock::now();
14 std::time_t t = system_clock::to_time_t( now );
15 std::tm buf{};
16#ifdef _WIN32
17 localtime_s( &buf, &t );
18#else
19 localtime_r( &t, &buf );
20#endif
21 char str[32];
22 std::strftime( str, sizeof( str ), "%Y-%m-%d %H:%M:%S", &buf );
23 return { str };
24}
25
26} // namespace terra::util
Definition solver.hpp:9
std::string current_timestamp()
Get the current timestamp as a string.
Definition timestamp.hpp:10