option: rename to to_string_opt and to_string_view_opt

to_option_string -> to_string_opt
to_string_view   -> to_string_view_opt
This commit is contained in:
Dirk-Jan C. Binnema
2022-04-16 13:16:29 +03:00
parent 4f9c154d1a
commit 7c51bc68d4
9 changed files with 104 additions and 77 deletions

View File

@ -43,6 +43,7 @@
#include "mu-util.h"
#include "mu-str.h"
#include "mu-error.hh"
#include "mu-option.hh"
using namespace Mu;
@ -352,14 +353,12 @@ Mu::time_to_string(const std::string& frm, time_t t, bool utc)
return {};
}
char* str = g_date_time_format(dt, frm.c_str()); /* always utf8 */
auto datestr{to_string_opt_gchar(g_date_time_format(dt, frm.c_str()))};
g_date_time_unref(dt);
if (!str) {
if (!datestr)
g_warning("failed to format time with format '%s'", frm.c_str());
return {};
}
return from_gchars(std::move(str)/*consumed*/);
return datestr.value_or("");
}
static std::string