diff options
author | ouwou <26526779+ouwou@users.noreply.github.com> | 2021-11-09 00:55:18 -0500 |
---|---|---|
committer | ouwou <26526779+ouwou@users.noreply.github.com> | 2021-11-09 00:55:18 -0500 |
commit | da561ba4d57f58ca44bf93e066e4c80d6b5266d9 (patch) | |
tree | 8315c247b308c0bbd437137111f43281fe7b9551 /discord | |
parent | c40b8a412272a7a407764166917cf3c61e7dc47f (diff) | |
download | abaddon-portaudio-da561ba4d57f58ca44bf93e066e4c80d6b5266d9.tar.gz abaddon-portaudio-da561ba4d57f58ca44bf93e066e4c80d6b5266d9.zip |
initial msys compatibility
Diffstat (limited to 'discord')
-rw-r--r-- | discord/snowflake.cpp | 11 | ||||
-rw-r--r-- | discord/snowflake.hpp | 2 |
2 files changed, 6 insertions, 7 deletions
diff --git a/discord/snowflake.cpp b/discord/snowflake.cpp index cea9153..6909a15 100644 --- a/discord/snowflake.cpp +++ b/discord/snowflake.cpp @@ -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) { diff --git a/discord/snowflake.hpp b/discord/snowflake.hpp index 0b79723..1cabf3d 100644 --- a/discord/snowflake.hpp +++ b/discord/snowflake.hpp @@ -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; |