forked from OpenGamers/abaddon
format timestamps and place them on the right (#17)
This commit is contained in:
@@ -1080,7 +1080,10 @@ ChatMessageHeader::ChatMessageHeader(const Message *data) {
|
|||||||
else if (data->WebhookID.has_value())
|
else if (data->WebhookID.has_value())
|
||||||
m_extra->set_markup("<b>Webhook</b>");
|
m_extra->set_markup("<b>Webhook</b>");
|
||||||
|
|
||||||
m_timestamp->set_text(data->Timestamp);
|
m_timestamp->set_text(data->ID.GetLocalTimestamp());
|
||||||
|
m_timestamp->set_hexpand(true);
|
||||||
|
m_timestamp->set_halign(Gtk::ALIGN_END);
|
||||||
|
m_timestamp->set_ellipsize(Pango::ELLIPSIZE_END);
|
||||||
m_timestamp->set_opacity(0.5);
|
m_timestamp->set_opacity(0.5);
|
||||||
m_timestamp->set_single_line_mode(true);
|
m_timestamp->set_single_line_mode(true);
|
||||||
m_timestamp->set_margin_start(12);
|
m_timestamp->set_margin_start(12);
|
||||||
@@ -1090,6 +1093,7 @@ ChatMessageHeader::ChatMessageHeader(const Message *data) {
|
|||||||
m_main_box->set_vexpand(true);
|
m_main_box->set_vexpand(true);
|
||||||
m_main_box->set_can_focus(true);
|
m_main_box->set_can_focus(true);
|
||||||
|
|
||||||
|
m_meta_box->set_hexpand(true);
|
||||||
m_meta_box->set_can_focus(false);
|
m_meta_box->set_can_focus(false);
|
||||||
|
|
||||||
m_content_box->set_can_focus(false);
|
m_content_box->set_can_focus(false);
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
#include "snowflake.hpp"
|
#include "snowflake.hpp"
|
||||||
|
#include <ctime>
|
||||||
|
#include <iomanip>
|
||||||
|
|
||||||
Snowflake::Snowflake()
|
Snowflake::Snowflake()
|
||||||
: m_num(Invalid) {}
|
: m_num(Invalid) {}
|
||||||
@@ -23,6 +25,16 @@ bool Snowflake::IsValid() const {
|
|||||||
return m_num != Invalid;
|
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) {
|
void from_json(const nlohmann::json &j, Snowflake &s) {
|
||||||
if (j.is_string()) {
|
if (j.is_string()) {
|
||||||
std::string tmp;
|
std::string tmp;
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ struct Snowflake {
|
|||||||
Snowflake(const Glib::ustring &str);
|
Snowflake(const Glib::ustring &str);
|
||||||
|
|
||||||
bool IsValid() const;
|
bool IsValid() const;
|
||||||
|
std::string GetLocalTimestamp() const;
|
||||||
|
|
||||||
bool operator==(const Snowflake &s) const noexcept {
|
bool operator==(const Snowflake &s) const noexcept {
|
||||||
return m_num == s.m_num;
|
return m_num == s.m_num;
|
||||||
|
|||||||
Reference in New Issue
Block a user