summaryrefslogtreecommitdiff
path: root/libedataserver
diff options
context:
space:
mode:
authorFridrich Strba <fridrich.strba@bluewin.ch>2009-07-03 13:24:01 +0200
committerFridrich Strba <fridrich.strba@bluewin.ch>2009-07-03 13:24:01 +0200
commit05ee9d50307e5ba1f4083f6d5a50ec9e141d2d94 (patch)
tree496c94411dc1b3bc217caef34ffdd0e3fce24363 /libedataserver
parentc80963d4421d6b2cd22a43742cc8031c7899b328 (diff)
downloadevolution-data-server-05ee9d50307e5ba1f4083f6d5a50ec9e141d2d94.tar.gz
Trying to port to win32 the nls_langinfo call.
Diffstat (limited to 'libedataserver')
-rw-r--r--libedataserver/e-time-utils.c25
1 files changed, 17 insertions, 8 deletions
diff --git a/libedataserver/e-time-utils.c b/libedataserver/e-time-utils.c
index d5d2d8cec..e9f45d6ed 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';