g_date_time_format: fix padding for some formats

%e is supposed to be space-padded and %W is supposed to be 0-padded

Adjust the testcase accordingly since it expects the wrong behaviour.
This commit is contained in:
Ryan Lortie
2011-09-02 19:33:32 -04:00
parent b4591aa3dc
commit 65fe8b73c5
2 changed files with 3 additions and 3 deletions

View File

@@ -2446,7 +2446,7 @@ g_date_time_format (GDateTime *datetime,
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));
break; break;
case 'e': case 'e':
get_numeric_format (fmt, sizeof(fmt), alt_digits, pad_set ? pad : 0, 2); get_numeric_format (fmt, sizeof(fmt), alt_digits, pad_set ? pad : ' ', 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));
break; break;
case 'g': case 'g':
@@ -2568,7 +2568,7 @@ g_date_time_format (GDateTime *datetime,
} }
break; break;
case 'W': case 'W':
get_numeric_format (fmt, sizeof(fmt), alt_digits, 0, 0); get_numeric_format (fmt, sizeof(fmt), alt_digits, '0', 2);
g_string_append_printf (outstr, fmt, g_date_time_get_day_of_year (datetime) / 7); g_string_append_printf (outstr, fmt, g_date_time_get_day_of_year (datetime) / 7);
break; break;
case 'x': case 'x':

View File

@@ -861,7 +861,7 @@ test_modifiers (void)
TEST_PRINTF_DATE (2009, 1, 21, "%-d", "21"); TEST_PRINTF_DATE (2009, 1, 21, "%-d", "21");
TEST_PRINTF_DATE (2009, 1, 21, "%0d", "21"); TEST_PRINTF_DATE (2009, 1, 21, "%0d", "21");
TEST_PRINTF_DATE (2009, 1, 1, "%e", "1"); TEST_PRINTF_DATE (2009, 1, 1, "%e", " 1");
TEST_PRINTF_DATE (2009, 1, 1, "%_e", " 1"); TEST_PRINTF_DATE (2009, 1, 1, "%_e", " 1");
TEST_PRINTF_DATE (2009, 1, 1, "%-e", "1"); TEST_PRINTF_DATE (2009, 1, 1, "%-e", "1");
TEST_PRINTF_DATE (2009, 1, 1, "%0e", "01"); TEST_PRINTF_DATE (2009, 1, 1, "%0e", "01");