GNOME Bugzilla – Bug 405469
wanted: g_strftime
Last modified: 2007-03-16 04:28:44 UTC
A lot of systems have the C89 system call strftime, taking a buffer, a format string f (IMHO arbitrary bytes with ASCII format specifiers) and a broken-down time t. It fills the buffer with a representation of t, based on the locale and f, in locale encoding. The return value is the number of bytes written, not counting the trailing \0, or 0 if an error occurs. == I am concerned about the following: * the representation is not in UTF-8 and must be post-processed for displaying * buffer filling always risks a buffer overflow and might also unnecessarily restrict what can be printed (maybe this is a subjective issue) * there is no definite way to detect errors, because empty strings are valid representations, e.g. given %p in many locales. * on Windows strftime must be used with care, see bug 404832. == What I would love to see: gchar * g_strftime (const gchar *format, const struct tm *tm); format - format string, in UTF-8, may contain normal text (and specifiers not available in the systems strftime, like %F on Windows?) tm - broken-down time Returns NULL on error or a UTF-8-encoded string represention of tm.
I already wrote a g_strftime() with exactly that prototype while working on my patch in bug #404832;) (Didn't attach that version yet, though.)
*** This bug has been marked as a duplicate of 69140 ***