diff options
author | Christopher James Lahey <clahey@ximian.com> | 2001-12-18 13:48:50 +0800 |
---|---|---|
committer | Chris Lahey <clahey@src.gnome.org> | 2001-12-18 13:48:50 +0800 |
commit | 67802a09c4d6b785dcd384c3e6029e73e0e5d681 (patch) | |
tree | 668e5f21770ebf4c32e43336b409a7e14e1022c8 /e-util | |
parent | f6408daa103092f18789a719a4123224b259f71f (diff) | |
download | gsoc2013-evolution-67802a09c4d6b785dcd384c3e6029e73e0e5d681.tar gsoc2013-evolution-67802a09c4d6b785dcd384c3e6029e73e0e5d681.tar.gz gsoc2013-evolution-67802a09c4d6b785dcd384c3e6029e73e0e5d681.tar.bz2 gsoc2013-evolution-67802a09c4d6b785dcd384c3e6029e73e0e5d681.tar.lz gsoc2013-evolution-67802a09c4d6b785dcd384c3e6029e73e0e5d681.tar.xz gsoc2013-evolution-67802a09c4d6b785dcd384c3e6029e73e0e5d681.tar.zst gsoc2013-evolution-67802a09c4d6b785dcd384c3e6029e73e0e5d681.zip |
Merging changes:
2001-12-17 Christopher James Lahey <clahey@ximian.com>
From a patch by Dan Nguyen <dnn@austin.ibm.com>
* 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
Diffstat (limited to 'e-util')
-rw-r--r-- | e-util/e-util.c | 40 | ||||
-rw-r--r-- | e-util/e-util.h | 5 |
2 files changed, 40 insertions, 5 deletions
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 <config.h> +#include "e-util.h" + #include <glib.h> #include <gtk/gtkobject.h> #include <errno.h> @@ -34,7 +37,6 @@ #include <stdlib.h> #include <time.h> -#include "e-util.h" #if 0 #include <libgnomevfs/gnome-vfs.h> #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); } } diff --git a/e-util/e-util.h b/e-util/e-util.h index fb8a8944ce..8ceeef0fa3 100644 --- a/e-util/e-util.h +++ b/e-util/e-util.h @@ -141,6 +141,11 @@ size_t e_strftime_fix_am_pm (char const char *fmt, const struct tm *tm); +size_t e_strftime (char *s, + size_t max, + const char *fmt, + const struct tm *tm); + /* String to/from double conversion functions */ gdouble e_flexible_strtod (const gchar *nptr, |