[evolution-data-server] Trying to port to win32 the nls_langinfo call.
- From: Fridrich Strba <strba src gnome org>
- To: svn-commits-list gnome org
- Subject: [evolution-data-server] Trying to port to win32 the nls_langinfo call.
- Date: Fri, 3 Jul 2009 11:24:25 +0000 (UTC)
commit 05ee9d50307e5ba1f4083f6d5a50ec9e141d2d94
Author: Fridrich Strba <fridrich strba bluewin ch>
Date: Fri Jul 3 13:24:01 2009 +0200
Trying to port to win32 the nls_langinfo call.
libedataserver/e-time-utils.c | 25 +++++++++++++++++--------
1 files changed, 17 insertions(+), 8 deletions(-)
---
diff --git a/libedataserver/e-time-utils.c b/libedataserver/e-time-utils.c
index d5d2d8c..e9f45d6 100644
--- a/libedataserver/e-time-utils.c
+++ b/libedataserver/e-time-utils.c
@@ -2028,16 +2028,25 @@ gchar *
e_time_get_d_fmt_with_4digit_year (void)
{
gchar *p;
- gchar *res =
- #if defined(__linux__)
- g_strdup (nl_langinfo (D_FMT) );
- /*#elif defined(G_OS_WIN32)
- **TODO** implement this for Win32 (GetLocaleInfo?) and/or other systems
+ gchar *res = NULL;
+#if defined(__linux__)
+ res = g_strdup (nl_langinfo (D_FMT) );
+#elif defined(G_OS_WIN32)
+ int format_string_length = GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_SLONGDATE, NULL, 0);
+ if (format_string_length > 0)
+ {
+ gchar *format_string = g_strnfill(format_string_length + 1, '\0');
+ GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_SLONGDATE, format_string, format_string_length);
+ gsize format_bytes_read, format_bytes_written;
+ res = g_locale_to_utf8(format_string, format_string_length, &format_bytes_read, &format_bytes_written, NULL);
+ g_free(format_string);
+ }
+ /**TODO** implement this for other systems
*/
- #else
+#else
/* this will not work for other systems */
- g_strdup ("%x");
- #endif
+ res = g_strdup ("%x");
+#endif
while (p = strchr (res, 'y'), p)
*p = 'Y';
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]