mirror of https://github.com/djcb/mu.git
utils: add fallback for time_to_string
Still don't understand issue #2230
This commit is contained in:
parent
7e1ecb63eb
commit
ffcb59bfd3
|
@ -341,20 +341,12 @@ Mu::vformat(const char* frm, va_list args)
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string
|
std::string
|
||||||
Mu::time_to_string(const std::string& frm, time_t t, bool utc)
|
Mu::time_to_string(const std::string& frm_, time_t t, bool utc)
|
||||||
{
|
{
|
||||||
/* Temporary... https://github.com/djcb/mu/issues/2230 */
|
/* Temporary hack... https://github.com/djcb/mu/issues/2230 */
|
||||||
{
|
const auto frm =
|
||||||
const char *end{};
|
g_utf8_validate(frm_.c_str(), frm_.length(), {}) ?
|
||||||
if (!g_utf8_validate(frm.c_str(), frm.length(), &end)) {
|
frm_ : "%c";
|
||||||
std::string hex{};
|
|
||||||
for (auto i = 0; i != end - frm.c_str(); ++i)
|
|
||||||
hex += format("%02x", frm[i]);
|
|
||||||
g_critical("%s: non-utf8 format (%s)",
|
|
||||||
__func__, hex.c_str());
|
|
||||||
return {};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
GDateTime* dt = std::invoke([&] {
|
GDateTime* dt = std::invoke([&] {
|
||||||
if (utc)
|
if (utc)
|
||||||
|
|
Loading…
Reference in New Issue