g_date_time_format: fix padding for some formats
authorRyan Lortie <desrt@desrt.ca>
Fri, 2 Sep 2011 23:33:32 +0000 (19:33 -0400)
committerRyan Lortie <desrt@desrt.ca>
Sat, 3 Sep 2011 01:05:23 +0000 (21:05 -0400)
%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.

glib/gdatetime.c
glib/tests/gdatetime.c

index 3c347c4..fa5cb08 100644 (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));
                   break;
                 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));
                   break;
                 case 'g':
@@ -2568,7 +2568,7 @@ g_date_time_format (GDateTime   *datetime,
                   }
                   break;
                 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);
                   break;
                 case 'x':
index 850a434..b22266b 100644 (file)
@@ -861,7 +861,7 @@ test_modifiers (void)
   TEST_PRINTF_DATE (2009, 1, 21, "%-d", "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, "%0e", "01");