diff --git a/glib/gdatetime.c b/glib/gdatetime.c index 66132838f..bba35df37 100644 --- a/glib/gdatetime.c +++ b/glib/gdatetime.c @@ -3132,6 +3132,10 @@ g_date_time_format_utf8 (GDateTime *datetime, format_number (outstr, alt_digits, pad_set ? pad : " ", 2, g_date_time_get_day_of_month (datetime)); break; + case 'f': + g_string_append_printf (outstr, "%06" G_GUINT64_FORMAT, + datetime->usec % G_TIME_SPAN_SECOND); + break; case 'F': g_string_append_printf (outstr, "%d-%02d-%02d", g_date_time_get_year (datetime), @@ -3323,7 +3327,7 @@ g_date_time_format_utf8 (GDateTime *datetime, * strftime() format language as specified by C99. The \%D, \%U and \%W * conversions are not supported, nor is the 'E' modifier. The GNU * extensions \%k, \%l, \%s and \%P are supported, however, as are the - * '0', '_' and '-' modifiers. + * '0', '_' and '-' modifiers. The Python extension \%f is also supported. * * In contrast to strftime(), this function always produces a UTF-8 * string, regardless of the current locale. Note that the rendering of @@ -3355,6 +3359,7 @@ g_date_time_format_utf8 (GDateTime *datetime, * single digits are preceded by a blank * - \%m: the month as a decimal number (range 01 to 12) * - \%M: the minute as a decimal number (range 00 to 59) + * - \%f: the microsecond as a decimal number (range 000000 to 999999) * - \%p: either "AM" or "PM" according to the given time value, or the * corresponding strings for the current locale. Noon is treated as * "PM" and midnight as "AM". Use of this format specifier is discouraged, as @@ -3399,7 +3404,7 @@ g_date_time_format_utf8 (GDateTime *datetime, * conversion specifier by one or more modifier characters. The * following modifiers are supported for many of the numeric * conversions: - * + * * - O: Use alternative numeric symbols, if the current locale supports those. * - _: Pad a numeric result with spaces. This overrides the default padding * for the specifier. diff --git a/glib/tests/gdatetime.c b/glib/tests/gdatetime.c index fb207be70..79a446e4b 100644 --- a/glib/tests/gdatetime.c +++ b/glib/tests/gdatetime.c @@ -1530,6 +1530,7 @@ GDateTime *__dt = g_date_time_new_local (2009, 10, 24, 0, 0, 0);\ TEST_PRINTF ("%d", "24"); TEST_PRINTF_DATE (2009, 1, 1, "%d", "01"); TEST_PRINTF ("%e", "24"); // fixme + TEST_PRINTF_TIME (10, 10, 1.001, "%f", "001000"); TEST_PRINTF ("%h", "Oct"); TEST_PRINTF ("%H", "00"); TEST_PRINTF_TIME (15, 0, 0, "%H", "15");