mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-02-04 18:26:19 +01:00
g_date_time_format: support %c
%c represents the preferred date and time representation for the current locale. https://bugzilla.gnome.org/show_bug.cgi?id=658061
This commit is contained in:
parent
b42d15490b
commit
6f80dc6042
@ -172,6 +172,7 @@ static const guint16 days_in_year[2][13] =
|
|||||||
nl_langinfo (AM_STR) : \
|
nl_langinfo (AM_STR) : \
|
||||||
nl_langinfo (PM_STR))
|
nl_langinfo (PM_STR))
|
||||||
|
|
||||||
|
#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)
|
||||||
|
|
||||||
@ -200,6 +201,9 @@ static const gint month_item[2][12] =
|
|||||||
/* Translators: 'after midday' indicator */ \
|
/* Translators: 'after midday' indicator */ \
|
||||||
: C_("GDateTime", "pm"))
|
: C_("GDateTime", "pm"))
|
||||||
|
|
||||||
|
/* Translators: this is the preferred format for expressing the date and the time */
|
||||||
|
#define PREFERRED_DATE_TIME_FMT C_("GDateTime", "%a %b %e %H:%M:%S %Y")
|
||||||
|
|
||||||
/* Translators: this is the preferred format for expressing the date */
|
/* Translators: this is the preferred format for expressing the date */
|
||||||
#define PREFERRED_DATE_FMT C_("GDateTime", "%m/%d/%y")
|
#define PREFERRED_DATE_FMT C_("GDateTime", "%m/%d/%y")
|
||||||
|
|
||||||
@ -2148,6 +2152,11 @@ get_numeric_format (gchar *fmt,
|
|||||||
* the full month name according to the current locale
|
* the full month name according to the current locale
|
||||||
* </simpara></listitem></varlistentry>
|
* </simpara></listitem></varlistentry>
|
||||||
* <varlistentry><term>
|
* <varlistentry><term>
|
||||||
|
* <literal>%%c</literal>:
|
||||||
|
* </term><listitem><simpara>
|
||||||
|
* the preferred date and time representation for the current locale
|
||||||
|
* </simpara></listitem></varlistentry>
|
||||||
|
* <varlistentry><term>
|
||||||
* <literal>%%d</literal>:
|
* <literal>%%d</literal>:
|
||||||
* </term><listitem><simpara>
|
* </term><listitem><simpara>
|
||||||
* the day of the month as a decimal number (range 01 to 31)
|
* the day of the month as a decimal number (range 01 to 31)
|
||||||
@ -2406,6 +2415,13 @@ g_date_time_format (GDateTime *datetime,
|
|||||||
case 'B':
|
case 'B':
|
||||||
g_string_append (outstr, MONTH_FULL (datetime));
|
g_string_append (outstr, MONTH_FULL (datetime));
|
||||||
break;
|
break;
|
||||||
|
case 'c':
|
||||||
|
{
|
||||||
|
tmp = g_date_time_format (datetime, PREFERRED_DATE_TIME_FMT);
|
||||||
|
g_string_append (outstr, tmp);
|
||||||
|
g_free (tmp);
|
||||||
|
}
|
||||||
|
break;
|
||||||
case 'd':
|
case 'd':
|
||||||
get_numeric_format (fmt, sizeof(fmt), alt_digits, pad_set ? pad : '0', 2);
|
get_numeric_format (fmt, sizeof(fmt), alt_digits, pad_set ? pad : '0', 2);
|
||||||
g_string_append_printf (outstr, fmt, g_date_time_get_day_of_month (datetime));
|
g_string_append_printf (outstr, fmt, g_date_time_get_day_of_month (datetime));
|
||||||
|
Loading…
Reference in New Issue
Block a user