1 From: Rafal Luzynski <digitalfreak@lingonborough.com>
2 Date: Sat, 10 Feb 2018 14:07:56 +0100
3 Subject: calendar: Use the new "%OB" format if supported
5 Due to the recent changes introduced in glibc 2.27 "%OB" is the
6 correct format to obtain a month name as used in the calendar
7 header. The same rule has been working in BSD family (including
8 OS X) since 1990s. This simple hack checks whether "%OB" is supported
9 at runtime and uses it if it is, falls back to the old "%B" otherwise.
12 Origin: upstream, 2.24.33, commit:2ea743ab466703091a44a74e1a4ac7db983c0bca
14 gtk/gtkcalendar.c | 19 +++++++++++++++++--
15 1 file changed, 17 insertions(+), 2 deletions(-)
17 diff --git a/gtk/gtkcalendar.c b/gtk/gtkcalendar.c
18 index 2dd68d6..28baba1 100644
19 --- a/gtk/gtkcalendar.c
20 +++ b/gtk/gtkcalendar.c
21 @@ -689,6 +689,7 @@ gtk_calendar_init (GtkCalendar *calendar)
25 + static const char *month_format = NULL;
29 @@ -714,7 +715,7 @@ gtk_calendar_init (GtkCalendar *calendar)
32 tmp_time= (i+3)*86400;
33 - strftime ( buffer, sizeof (buffer), "%a", gmtime (&tmp_time));
34 + strftime (buffer, sizeof (buffer), "%a", gmtime (&tmp_time));
35 default_abbreviated_dayname[i] = g_locale_to_utf8 (buffer, -1, NULL, NULL, NULL);
37 if (!GetLocaleInfoW (GetThreadLocale (), LOCALE_SABBREVDAYNAME1 + (i+6)%7,
38 @@ -730,7 +731,21 @@ gtk_calendar_init (GtkCalendar *calendar)
42 - strftime ( buffer, sizeof (buffer), "%B", gmtime (&tmp_time));
43 + if (G_UNLIKELY (month_format == NULL))
46 + month_format = "%OB";
47 + strftime (buffer, sizeof (buffer), month_format, gmtime (&tmp_time));
48 + /* "%OB" is not supported in Linux with glibc < 2.27 */
49 + if (!strcmp (buffer, "%OB") || !strcmp (buffer, "OB") || !strcmp (buffer, ""))
51 + month_format = "%B";
52 + strftime (buffer, sizeof (buffer), month_format, gmtime (&tmp_time));
56 + strftime (buffer, sizeof (buffer), month_format, gmtime (&tmp_time));
58 default_monthname[i] = g_locale_to_utf8 (buffer, -1, NULL, NULL, NULL);
60 if (!GetLocaleInfoW (GetThreadLocale (), LOCALE_SMONTHNAME1 + i,