mirror of
https://github.com/celisej567/abaddon.git
synced 2026-09-13 20:18:50 +03:00
format timestamps and place them on the right (#17)
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
#include "snowflake.hpp"
|
||||
#include <ctime>
|
||||
#include <iomanip>
|
||||
|
||||
Snowflake::Snowflake()
|
||||
: m_num(Invalid) {}
|
||||
@@ -23,6 +25,16 @@ bool Snowflake::IsValid() const {
|
||||
return m_num != Invalid;
|
||||
}
|
||||
|
||||
std::string Snowflake::GetLocalTimestamp() const {
|
||||
const time_t secs_since_epoch = (m_num / 4194304000) + 1420070400;
|
||||
const std::tm tm = *localtime(&secs_since_epoch);
|
||||
std::stringstream ss;
|
||||
const static std::locale locale("");
|
||||
ss.imbue(locale);
|
||||
ss << std::put_time(&tm, "%X %x");
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
void from_json(const nlohmann::json &j, Snowflake &s) {
|
||||
if (j.is_string()) {
|
||||
std::string tmp;
|
||||
|
||||
Reference in New Issue
Block a user