mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-02-10 12:55:48 +01:00
win32_strftime_helper: Factor out the common code
Factor out the common code supporting "%B", "%b", and "%h" format specifiers. It will be helpful for the next commit. https://bugzilla.gnome.org/show_bug.cgi?id=749206
This commit is contained in:
parent
9152244828
commit
5520a87930
27
glib/gdate.c
27
glib/gdate.c
@ -2133,6 +2133,23 @@ g_date_order (GDate *date1,
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef G_OS_WIN32
|
#ifdef G_OS_WIN32
|
||||||
|
static void
|
||||||
|
append_month_name (GArray *result,
|
||||||
|
LCID lcid,
|
||||||
|
SYSTEMTIME *systemtime,
|
||||||
|
gboolean abbreviated)
|
||||||
|
{
|
||||||
|
int n;
|
||||||
|
WORD base;
|
||||||
|
|
||||||
|
base = abbreviated ? LOCALE_SABBREVMONTHNAME1 : LOCALE_SMONTHNAME1;
|
||||||
|
n = GetLocaleInfoW (lcid, base + systemtime->wMonth - 1, NULL, 0);
|
||||||
|
g_array_set_size (result, result->len + n);
|
||||||
|
GetLocaleInfoW (lcid, base + systemtime->wMonth - 1,
|
||||||
|
((wchar_t *) result->data) + result->len - n, n);
|
||||||
|
g_array_set_size (result, result->len - 1);
|
||||||
|
}
|
||||||
|
|
||||||
static gsize
|
static gsize
|
||||||
win32_strftime_helper (const GDate *d,
|
win32_strftime_helper (const GDate *d,
|
||||||
const gchar *format,
|
const gchar *format,
|
||||||
@ -2219,16 +2236,10 @@ win32_strftime_helper (const GDate *d,
|
|||||||
break;
|
break;
|
||||||
case 'b':
|
case 'b':
|
||||||
case 'h':
|
case 'h':
|
||||||
n = GetLocaleInfoW (lcid, LOCALE_SABBREVMONTHNAME1+systemtime.wMonth-1, NULL, 0);
|
append_month_name (result, lcid, &systemtime, TRUE);
|
||||||
g_array_set_size (result, result->len + n);
|
|
||||||
GetLocaleInfoW (lcid, LOCALE_SABBREVMONTHNAME1+systemtime.wMonth-1, ((wchar_t *) result->data) + result->len - n, n);
|
|
||||||
g_array_set_size (result, result->len - 1);
|
|
||||||
break;
|
break;
|
||||||
case 'B':
|
case 'B':
|
||||||
n = GetLocaleInfoW (lcid, LOCALE_SMONTHNAME1+systemtime.wMonth-1, NULL, 0);
|
append_month_name (result, lcid, &systemtime, FALSE);
|
||||||
g_array_set_size (result, result->len + n);
|
|
||||||
GetLocaleInfoW (lcid, LOCALE_SMONTHNAME1+systemtime.wMonth-1, ((wchar_t *) result->data) + result->len - n, n);
|
|
||||||
g_array_set_size (result, result->len - 1);
|
|
||||||
break;
|
break;
|
||||||
case 'c':
|
case 'c':
|
||||||
n = GetDateFormatW (lcid, 0, &systemtime, NULL, NULL, 0);
|
n = GetDateFormatW (lcid, 0, &systemtime, NULL, NULL, 0);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user