mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-02-02 17:26:17 +01:00
g_date_time_format: honour T_FMT_AMPM for '%r'
We had the 12 hour time format hard-coded to "%02d:%02d:%02d %s" but it actually changes depending on the locale. Just with the other formats, use nl_langinfo() if we have it, otherwise fall back on gettext().
This commit is contained in:
parent
9ddd25c18b
commit
b6fdbb8e44
@ -1323,8 +1323,10 @@ AC_CACHE_CHECK([for nl_langinfo (PM_STR)],glib_cv_langinfo_time,[
|
|||||||
AC_TRY_COMPILE([#include <langinfo.h>],
|
AC_TRY_COMPILE([#include <langinfo.h>],
|
||||||
[char *str;
|
[char *str;
|
||||||
str = nl_langinfo (PM_STR);
|
str = nl_langinfo (PM_STR);
|
||||||
|
str = nl_langinfo (D_T_FMT);
|
||||||
str = nl_langinfo (D_FMT);
|
str = nl_langinfo (D_FMT);
|
||||||
str = nl_langinfo (T_FMT);
|
str = nl_langinfo (T_FMT);
|
||||||
|
str = nl_langinfo (T_FMT_AMPM);
|
||||||
str = nl_langinfo (MON_1);
|
str = nl_langinfo (MON_1);
|
||||||
str = nl_langinfo (ABMON_12);
|
str = nl_langinfo (ABMON_12);
|
||||||
str = nl_langinfo (DAY_1);
|
str = nl_langinfo (DAY_1);
|
||||||
|
@ -175,6 +175,8 @@ static const guint16 days_in_year[2][13] =
|
|||||||
#define PREFERRED_DATE_TIME_FMT nl_langinfo (D_T_FMT)
|
#define PREFERRED_DATE_TIME_FMT nl_langinfo (D_T_FMT)
|
||||||
#define PREFERRED_DATE_FMT nl_langinfo (D_FMT)
|
#define PREFERRED_DATE_FMT nl_langinfo (D_FMT)
|
||||||
#define PREFERRED_TIME_FMT nl_langinfo (T_FMT)
|
#define PREFERRED_TIME_FMT nl_langinfo (T_FMT)
|
||||||
|
#define PREFERRED_TIME_FMT nl_langinfo (T_FMT)
|
||||||
|
#define PREFERRED_12HR_TIME_FMT nl_langinfo (T_FMT_AMPM)
|
||||||
|
|
||||||
static const gint weekday_item[2][7] =
|
static const gint weekday_item[2][7] =
|
||||||
{
|
{
|
||||||
@ -210,6 +212,8 @@ static const gint month_item[2][12] =
|
|||||||
/* Translators: this is the preferred format for expressing the time */
|
/* Translators: this is the preferred format for expressing the time */
|
||||||
#define PREFERRED_TIME_FMT C_("GDateTime", "%H:%M:%S")
|
#define PREFERRED_TIME_FMT C_("GDateTime", "%H:%M:%S")
|
||||||
|
|
||||||
|
/* Translators: this is the preferred format for expressing 12 hour time */
|
||||||
|
#define PREFERRED_12HR_TIME_FMT C_("GDateTime", "%I:%M:%S %p")
|
||||||
|
|
||||||
#define WEEKDAY_ABBR(d) (get_weekday_name_abbr (g_date_time_get_day_of_week (d)))
|
#define WEEKDAY_ABBR(d) (get_weekday_name_abbr (g_date_time_get_day_of_week (d)))
|
||||||
#define WEEKDAY_FULL(d) (get_weekday_name (g_date_time_get_day_of_week (d)))
|
#define WEEKDAY_FULL(d) (get_weekday_name (g_date_time_get_day_of_week (d)))
|
||||||
@ -2535,16 +2539,9 @@ g_date_time_format (GDateTime *datetime,
|
|||||||
break;
|
break;
|
||||||
case 'r':
|
case 'r':
|
||||||
{
|
{
|
||||||
gint hour = g_date_time_get_hour (datetime) % 12;
|
tmp = g_date_time_format (datetime, PREFERRED_12HR_TIME_FMT);
|
||||||
if (hour == 0)
|
g_string_append (outstr, tmp);
|
||||||
hour = 12;
|
g_free (tmp);
|
||||||
ampm = g_utf8_strup (GET_AMPM (datetime), -1);
|
|
||||||
g_string_append_printf (outstr, "%02d:%02d:%02d %s",
|
|
||||||
hour,
|
|
||||||
g_date_time_get_minute (datetime),
|
|
||||||
g_date_time_get_second (datetime),
|
|
||||||
ampm);
|
|
||||||
g_free (ampm);
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'R':
|
case 'R':
|
||||||
|
Loading…
Reference in New Issue
Block a user