[glib] g_date_time_format: fix padding for some formats



commit 65fe8b73c50b89358732e0c0d093587b62a1cea0
Author: Ryan Lortie <desrt desrt ca>
Date:   Fri Sep 2 19:33:32 2011 -0400

    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.

 glib/gdatetime.c       |    4 ++--
 glib/tests/gdatetime.c |    2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)
---
diff --git a/glib/gdatetime.c b/glib/gdatetime.c
index 3c347c4..fa5cb08 100644
--- a/glib/gdatetime.c
+++ b/glib/gdatetime.c
@@ -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':
diff --git a/glib/tests/gdatetime.c b/glib/tests/gdatetime.c
index 850a434..b22266b 100644
--- a/glib/tests/gdatetime.c
+++ b/glib/tests/gdatetime.c
@@ -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");



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]