Joedb 9.5.0
The Journal-Only Embedded Database
Loading...
Searching...
No Matches
get_time_string.cpp
Go to the documentation of this file.
2
3#include <ctime>
4
5namespace joedb
6{
7 /////////////////////////////////////////////////////////////////////////////
8 std::string get_time_string(int64_t timestamp)
9 /////////////////////////////////////////////////////////////////////////////
10 {
11 constexpr size_t buffer_size = 24;
12 char buffer[buffer_size];
13 const time_t stamp = time_t(timestamp);
14 struct tm tm;
15#if defined(__unix__)
16 gmtime_r(&stamp, &tm);
17#else
18 tm = *std::gmtime(&stamp);
19#endif
20 std::strftime(buffer, buffer_size, "%Y-%m-%d %H:%M:%S GMT", &tm);
21
22 return std::string(buffer);
23 }
24
25 /////////////////////////////////////////////////////////////////////////////
27 /////////////////////////////////////////////////////////////////////////////
28 {
29 return get_time_string(std::time(nullptr));
30 }
31}
std::string get_time_string(int64_t timestamp)
std::string get_time_string_of_now()
Definition Blob.h:7