utils: add Mu::time_to_string

Helper function to format strings (a-la strftime).
This commit is contained in:
Dirk-Jan C. Binnema
2021-11-10 21:32:46 +02:00
parent 0cbd18e7a5
commit c9e958d65c
2 changed files with 44 additions and 0 deletions

View File

@ -129,6 +129,19 @@ std::string date_to_time_t_string(const std::string& date, bool first);
*/
std::string date_to_time_t_string(int64_t t);
/**
* Get a string for a given time_t and format
* memory that must be freed after use.
*
* @param frm the format of the string (in strftime(3) format)
* @param t the time as time_t
* @param utc whether to display as UTC(if true) or local time
*
* @return a string representation of the time in UTF8-format, or empty in case
* of error.
*/
std::string time_to_string(const std::string& frm, time_t t, bool utc = false) G_GNUC_CONST;
/**
* Create a std::string by consuming a gchar* array; this takes ownership
* of str which should no longer be used.