From 67802a09c4d6b785dcd384c3e6029e73e0e5d681 Mon Sep 17 00:00:00 2001 From: Christopher James Lahey Date: Tue, 18 Dec 2001 05:48:50 +0000 Subject: Merging changes: 2001-12-17 Christopher James Lahey From a patch by Dan Nguyen * configure.in: Added configure check for %l and %k in strftime. * gal/util/e-util.c, gal/util/e-util.h (e_strftime): New function. Handles %l and %k even on platforms that don't support them by translating to %I and %H. svn path=/trunk/; revision=15146 --- e-util/e-util.c | 40 +++++++++++++++++++++++++++++++++++----- 1 file changed, 35 insertions(+), 5 deletions(-) (limited to 'e-util/e-util.c') diff --git a/e-util/e-util.c b/e-util/e-util.c index ac775e92bd..98bc8db898 100644 --- a/e-util/e-util.c +++ b/e-util/e-util.c @@ -21,6 +21,9 @@ * 02111-1307, USA. */ +#include +#include "e-util.h" + #include #include #include @@ -34,7 +37,6 @@ #include #include -#include "e-util.h" #if 0 #include #endif @@ -1167,6 +1169,34 @@ e_sort (void *base, #endif } +size_t e_strftime(char *s, size_t max, const char *fmt, const struct tm *tm) +{ +#ifdef HAVE_LKSTRFTIME + return strftime(s, max, fmt, tm); +#else + char *c, *ffmt, *ff; + size_t ret; + + ffmt = g_strdup(fmt); + ff = ffmt; + while ((c = strstr(ff, "%l")) != NULL) { + c[1] = 'I'; + ff = c; + } + + ff = fmt; + while ((c = strstr(ff, "%k")) != NULL) { + c[1] = 'H'; + ff = c; + } + + ret = strftime(s, max, ffmt, tm); + g_free(ffmt); + return ret; +#endif +} + + /** * Function to do a last minute fixup of the AM/PM stuff if the locale * and gettext haven't done it right. Most English speaking countries @@ -1194,17 +1224,17 @@ size_t e_strftime_fix_am_pm(char *s, size_t max, const char *fmt, const struct t if (strstr(fmt, "%p")==NULL && strstr(fmt, "%P")==NULL) { /* No AM/PM involved - can use the fmt string directly */ - ret=strftime(s, max, fmt, tm); + ret=e_strftime(s, max, fmt, tm); } else { /* Get the AM/PM symbol from the locale */ - strftime (buf, 10, "%p", tm); + e_strftime (buf, 10, "%p", tm); if (buf[0]) { /** * AM/PM have been defined in the locale * so we can use the fmt string directly **/ - ret=strftime(s, max, fmt, tm); + ret=e_strftime(s, max, fmt, tm); } else { /** * No AM/PM defined by locale @@ -1221,7 +1251,7 @@ size_t e_strftime_fix_am_pm(char *s, size_t max, const char *fmt, const struct t for (sp=ffmt; (sp=strstr(sp, "%I")); sp++) { sp[1]='H'; } - ret=strftime(s, max, ffmt, tm); + ret=e_strftime(s, max, ffmt, tm); g_free(ffmt); } } -- cgit