[glib] g_date_time_format: support %w



commit f421f0b88323b2a07d3cf18bf2aa3e2acf509738
Author: Javier JardÃn <jjardon gnome org>
Date:   Fri Sep 2 17:22:14 2011 +0100

    g_date_time_format: support %w
    
    %w represents the day of the week as a decimal, range 0 to 6,
    Sunday being 0.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=658061

 glib/gdatetime.c |   14 ++++++++++++++
 1 files changed, 14 insertions(+), 0 deletions(-)
---
diff --git a/glib/gdatetime.c b/glib/gdatetime.c
index e37857d..eeca45f 100644
--- a/glib/gdatetime.c
+++ b/glib/gdatetime.c
@@ -2283,6 +2283,11 @@ get_numeric_format (gchar    *fmt,
  *    4 days in the new year. See g_date_time_get_week_of_year().
  *  </simpara></listitem></varlistentry>
  *  <varlistentry><term>
+ *    <literal>%%w</literal>:
+ *   </term><listitem><simpara>
+ *    the day of the week as a decimal, range 0 to 6, Sunday being  0
+ *  </simpara></listitem></varlistentry>
+ *  <varlistentry><term>
  *    <literal>%%W</literal>:
  *   </term><listitem><simpara>
  *    the week number of the current year as a decimal number
@@ -2544,6 +2549,15 @@ g_date_time_format (GDateTime   *datetime,
                   get_numeric_format (fmt, sizeof(fmt), alt_digits, '0', 2);
                   g_string_append_printf (outstr, fmt, g_date_time_get_week_of_year (datetime));
                   break;
+                case 'w':
+                  {
+                    gint day_of_week = g_date_time_get_day_of_week (datetime);
+                    if (day_of_week == 7)
+                      day_of_week = 0;
+                    get_numeric_format (fmt, sizeof(fmt), alt_digits, 0, 0);
+                    g_string_append_printf (outstr, fmt, day_of_week);
+                  }
+                  break;
                 case 'W':
                   get_numeric_format (fmt, sizeof(fmt), alt_digits, 0, 0);
                   g_string_append_printf (outstr, fmt, g_date_time_get_day_of_year (datetime) / 7);



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