GNOME Bugzilla – Bug 69140
We should have a g_utf8_strftime()
Last modified: 2011-02-18 16:13:49 UTC
There is a need for strftime() equivalent, which accepts UTF-8 format string, and returns UTF-8 string. Also, it should return a newly-allocated string of needed size, as other glib functions do. You might want to look at what glib/gunicollate.c does with wcscoll; using wcsftime when available and the wcs encoding is appropriate can give you a properly Unicode "strftime" independent of the locale. When wcsftime is not available, g_utf8_strftime should convert format string to locale encoding, call strftime, and convert result back into utf-8 (look at eel/eel-glib-extensions.c for example). The same improvement could be made to g_date_strftime
Created attachment 6454 [details] [review] This patch implements g_utf8_strftime function
Created attachment 6455 [details] [review] makes g_date_strftime use wcsftime which should be much more efficient than converting and using strftime.
I have created a new bug 83145 for g_date_strftime optimization. This implementation of g_utf8_strftime does not care if buffer passed to strftime is long enough, but I guess it should, as g_date_strftime does.
strftime has the worst possible buffer management handling imaginable. If we add something in this area it shouldn't be called strftime or act exactly like strftime. char *g_format_time (const char *format, const struct tm *time); Would be my preference. But this probably shoudl actually be done within the framework of bug 50076.
*** Bug 58573 has been marked as a duplicate of this bug. ***
There are some extensions to the strftime specifiers that are needed, and that would be excellent to have in a glib equivalent of strftime. See bug 127349 for one example.
See also bug #325064, which is about a simpler API for formatting dates/times.
*** Bug 405469 has been marked as a duplicate of this bug. ***
This is covered by the api in bug 50076 *** This bug has been marked as a duplicate of bug 50076 ***