aboutsummaryrefslogtreecommitdiffstats
path: root/e-util
diff options
context:
space:
mode:
authorMike Kestner <mkestner@ximian.com>2003-05-29 05:32:52 +0800
committerMike Kestner <mkestner@src.gnome.org>2003-05-29 05:32:52 +0800
commit0701e570aaf7fe4a4148c623200f1edca28c8220 (patch)
tree294dc20940c5db96d91c1a93b14047235ef4a113 /e-util
parent64c7a53a4d0ac4c3c855073203a4393464a1f5cf (diff)
downloadgsoc2013-evolution-0701e570aaf7fe4a4148c623200f1edca28c8220.tar.gz
gsoc2013-evolution-0701e570aaf7fe4a4148c623200f1edca28c8220.tar.zst
gsoc2013-evolution-0701e570aaf7fe4a4148c623200f1edca28c8220.zip
bump libtool version for api addition new, utf8 in/out
2003-05-28 Mike Kestner <mkestner@ximian.com> * configure.in : bump libtool version for api addition * gal/util/e-util.c (e_utf8_strftime): new, utf8 in/out (e_utf8_strftime_fix_am_pm): new, utf8 in/out 2003-05-28 Mike Kestner <mkestner@ximian.com> * e-cell-date.c (ecd_get_text): use e_utf8_strftime_fix_am_pm and remove locale to utf8 conversion at end. [43485] svn path=/trunk/; revision=21343
Diffstat (limited to 'e-util')
-rw-r--r--e-util/e-util.c43
-rw-r--r--e-util/e-util.h10
2 files changed, 53 insertions, 0 deletions
diff --git a/e-util/e-util.c b/e-util/e-util.c
index 46be2143f7..03fda380e1 100644
--- a/e-util/e-util.c
+++ b/e-util/e-util.c
@@ -768,6 +768,27 @@ size_t e_strftime(char *s, size_t max, const char *fmt, const struct tm *tm)
#endif
}
+size_t
+e_utf8_strftime(char *s, size_t max, const char *fmt, const struct tm *tm)
+{
+ size_t sz;
+ char *locale_fmt = g_locale_from_utf8(fmt, -1, NULL, &sz, NULL);
+ size_t ret = e_strftime(s, max, locale_fmt, tm);
+ char *buf = g_locale_to_utf8(s, ret, NULL, &sz, NULL);
+ if (sz >= max) {
+ char *tmp = buf + max - 1;
+ tmp = g_utf8_find_prev_char(buf, tmp);
+ if (tmp)
+ sz = tmp - buf;
+ else
+ sz = 0;
+ }
+ memcpy(s, buf, sz);
+ s[sz] = '\0';
+ g_free(locale_fmt);
+ g_free(buf);
+ return sz;
+}
/**
* Function to do a last minute fixup of the AM/PM stuff if the locale
@@ -830,6 +851,28 @@ size_t e_strftime_fix_am_pm(char *s, size_t max, const char *fmt, const struct t
return(ret);
}
+size_t
+e_utf8_strftime_fix_am_pm(char *s, size_t max, const char *fmt, const struct tm *tm)
+{
+ size_t sz;
+ char *locale_fmt = g_locale_from_utf8(fmt, -1, NULL, &sz, NULL);
+ size_t ret = e_strftime_fix_am_pm(s, max, locale_fmt, tm);
+ char *buf = g_locale_to_utf8(s, ret, NULL, &sz, NULL);
+ if (sz >= max) {
+ char *tmp = buf + max - 1;
+ tmp = g_utf8_find_prev_char(buf, tmp);
+ if (tmp)
+ sz = tmp - buf;
+ else
+ sz = 0;
+ }
+ memcpy(s, buf, sz);
+ s[sz] = '\0';
+ g_free(locale_fmt);
+ g_free(buf);
+ return sz;
+}
+
/**
* e_flexible_strtod:
* @nptr: the string to convert to a numeric value.
diff --git a/e-util/e-util.h b/e-util/e-util.h
index 2937265f6b..d9d51967d1 100644
--- a/e-util/e-util.h
+++ b/e-util/e-util.h
@@ -196,6 +196,16 @@ size_t e_strftime (char *s,
const char *fmt,
const struct tm *tm);
+size_t e_utf8_strftime_fix_am_pm (char *s,
+ size_t max,
+ const char *fmt,
+ const struct tm *tm);
+
+size_t e_utf8_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,
gchar **endptr);