After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 405469 - wanted: g_strftime
wanted: g_strftime
Status: RESOLVED DUPLICATE of bug 69140
Product: glib
Classification: Platform
Component: general
Other All
: Normal enhancement
: ---
Assigned To: gtkdev
Depends on:
Reported: 2007-02-07 18:43 UTC by Andreas Köhler
Modified: 2007-03-16 04:28 UTC
See Also:
GNOME target: ---
GNOME version: ---

Description Andreas Köhler 2007-02-07 18:43:00 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.
Comment 1 Tor Lillqvist 2007-02-07 19:20:20 UTC
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.)
Comment 2 Matthias Clasen 2007-03-16 04:28:44 UTC

*** This bug has been marked as a duplicate of 69140 ***