mirror of
https://github.com/celisej567/abaddon.git
synced 2026-09-06 20:15:19 +03:00
initial msys compatibility
This commit is contained in:
11
abaddon.cpp
11
abaddon.cpp
@@ -728,6 +728,17 @@ EmojiResource &Abaddon::GetEmojis() {
|
||||
int main(int argc, char **argv) {
|
||||
if (std::getenv("ABADDON_NO_FC") == nullptr)
|
||||
Platform::SetupFonts();
|
||||
|
||||
char *systemLocale = std::setlocale(LC_ALL, "");
|
||||
try {
|
||||
std::locale::global(std::locale(systemLocale));
|
||||
} catch (...) {
|
||||
try {
|
||||
std::locale::global(std::locale::classic());
|
||||
std::setlocale(LC_ALL, systemLocale);
|
||||
} catch (...) {}
|
||||
}
|
||||
|
||||
#if defined(_WIN32) && defined(_MSC_VER)
|
||||
TCHAR buf[2] { 0 };
|
||||
GetEnvironmentVariableA("GTK_CSD", buf, sizeof(buf));
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#include <ctime>
|
||||
#include <iomanip>
|
||||
#include <chrono>
|
||||
#include <glibmm.h>
|
||||
|
||||
constexpr static uint64_t DiscordEpochSeconds = 1420070400;
|
||||
|
||||
@@ -42,14 +43,12 @@ bool Snowflake::IsValid() const {
|
||||
return m_num != Invalid;
|
||||
}
|
||||
|
||||
std::string Snowflake::GetLocalTimestamp() const {
|
||||
Glib::ustring Snowflake::GetLocalTimestamp() const {
|
||||
const time_t secs_since_epoch = (m_num / SecondsInterval) + DiscordEpochSeconds;
|
||||
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();
|
||||
std::array<char, 256> tmp;
|
||||
std::strftime(tmp.data(), sizeof(tmp), "%X %x", &tm);
|
||||
return tmp.data();
|
||||
}
|
||||
|
||||
void from_json(const nlohmann::json &j, Snowflake &s) {
|
||||
|
||||
@@ -12,7 +12,7 @@ struct Snowflake {
|
||||
static Snowflake FromNow(); // not thread safe
|
||||
|
||||
bool IsValid() const;
|
||||
std::string GetLocalTimestamp() const;
|
||||
Glib::ustring GetLocalTimestamp() const;
|
||||
|
||||
bool operator==(const Snowflake &s) const noexcept {
|
||||
return m_num == s.m_num;
|
||||
|
||||
9
util.cpp
9
util.cpp
@@ -1,5 +1,6 @@
|
||||
#include "util.hpp"
|
||||
#include <filesystem>
|
||||
#include <array>
|
||||
|
||||
Semaphore::Semaphore(int count)
|
||||
: m_count(count) {}
|
||||
@@ -93,11 +94,9 @@ std::string FormatISO8601(const std::string &in, int extra_offset, const std::st
|
||||
int offset = GetTimezoneOffset();
|
||||
tm.tm_sec += offset + extra_offset;
|
||||
mktime(&tm);
|
||||
std::stringstream ss;
|
||||
const static std::locale locale("");
|
||||
ss.imbue(locale);
|
||||
ss << std::put_time(&tm, fmt.c_str());
|
||||
return ss.str();
|
||||
std::array<char, 512> tmp;
|
||||
std::strftime(tmp.data(), sizeof(tmp), fmt.c_str(), &tm);
|
||||
return tmp.data();
|
||||
}
|
||||
|
||||
void ScrollListBoxToSelected(Gtk::ListBox &list) {
|
||||
|
||||
Reference in New Issue
Block a user