28 #include "gnc-date-p.h" 33 static GHashTable *picture_to_format = NULL;
34 G_LOCK_DEFINE_STATIC(picture_to_format);
37 qof_time_format_from_utf8(
const gchar *utf8_format)
39 wchar_t* utf16_format;
43 utf16_format =
reinterpret_cast<wchar_t*
>(g_utf8_to_utf16(utf8_format, -1,
49 count = wcstombs(NULL, utf16_format, 0);
54 retval =
static_cast<gchar*
>(g_malloc((count + 1) *
sizeof(gchar)));
55 count = wcstombs(retval, utf16_format, count + 1);
67 qof_formatted_time_to_utf8(
const gchar *locale_string)
69 gunichar2 *utf16_string;
74 count = mbstowcs(NULL, locale_string, 0);
79 utf16_string =
static_cast<gunichar2*
>(g_malloc((count + 1) *
sizeof(gunichar2)));
80 count = mbstowcs(reinterpret_cast<wchar_t*>(utf16_string),
81 locale_string, count + 1);
88 retval = g_utf16_to_utf8(utf16_string, -1, NULL, NULL, NULL);
95 qof_win32_get_time_format(QofWin32Picture picture)
97 gchar *locale_string, *format;
102 case QOF_WIN32_PICTURE_DATE:
103 locale_string = get_win32_locale_string(LOCALE_SSHORTDATE);
105 case QOF_WIN32_PICTURE_TIME:
106 locale_string = get_win32_locale_string(LOCALE_STIMEFORMAT);
108 case QOF_WIN32_PICTURE_DATETIME:
109 tmp1 = get_win32_locale_string(LOCALE_SSHORTDATE);
110 tmp2 = get_win32_locale_string(LOCALE_STIMEFORMAT);
111 locale_string = g_strconcat(tmp1,
" ", tmp2, NULL);
116 g_assert_not_reached();
119 G_LOCK(picture_to_format);
120 if (!picture_to_format)
121 picture_to_format = g_hash_table_new_full(g_str_hash, g_str_equal,
123 format =
static_cast<char*
>(g_hash_table_lookup(picture_to_format, locale_string));
126 format = translate_win32_picture(locale_string);
127 g_hash_table_insert(picture_to_format, g_strdup(locale_string), format);
129 G_UNLOCK(picture_to_format);
130 g_free(locale_string);