mirror of
https://github.com/celisej567/abaddon.git
synced 2026-09-27 16:16:35 +03:00
show pending/failed messages
css changes: - added .failed - added .pending
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
#include "snowflake.hpp"
|
||||
#include <ctime>
|
||||
#include <iomanip>
|
||||
#include <chrono>
|
||||
|
||||
constexpr static uint64_t DiscordEpochSeconds = 1420070400;
|
||||
|
||||
Snowflake::Snowflake()
|
||||
: m_num(Invalid) {}
|
||||
@@ -21,6 +24,18 @@ Snowflake::Snowflake(const Glib::ustring &str) {
|
||||
m_num = Invalid;
|
||||
};
|
||||
|
||||
Snowflake Snowflake::FromNow() {
|
||||
using namespace std::chrono;
|
||||
// not guaranteed to work but it probably will anyway
|
||||
static uint64_t counter = 0;
|
||||
const auto millis_since_epoch = static_cast<uint64_t>(duration_cast<milliseconds>(system_clock::now().time_since_epoch()).count());
|
||||
const auto epoch = millis_since_epoch - DiscordEpochSeconds * 1000;
|
||||
uint64_t snowflake = epoch << 22;
|
||||
// worker id and process id would be OR'd in here but there's no point
|
||||
snowflake |= counter++ % 4096;
|
||||
return snowflake;
|
||||
}
|
||||
|
||||
bool Snowflake::IsValid() const {
|
||||
return m_num != Invalid;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user