Joedb
9.5.0
The Journal-Only Embedded Database
Loading...
Searching...
No Matches
src
joedb
ui
get_time_string.cpp
Go to the documentation of this file.
1
#include "
joedb/ui/get_time_string.h
"
2
3
#include <ctime>
4
5
namespace
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
/////////////////////////////////////////////////////////////////////////////
26
std::string
get_time_string_of_now
()
27
/////////////////////////////////////////////////////////////////////////////
28
{
29
return
get_time_string
(std::time(
nullptr
));
30
}
31
}
get_time_string.h
joedb::get_time_string
std::string get_time_string(int64_t timestamp)
Definition
get_time_string.cpp:8
joedb::get_time_string_of_now
std::string get_time_string_of_now()
Definition
get_time_string.cpp:26
joedb
Definition
Blob.h:7
Generated by
1.9.8