[glib] g_date_time_format: support %T



commit 414c8ce532c19fe65deb8dfb80222d0164be5cbe
Author: Matthias Clasen <mclasen redhat com>
Date:   Sun Aug 21 19:51:45 2011 -0400

    g_date_time_format: support %T
    
    strftime supports it, and there is no reason not to do the same.

 glib/gdatetime.c |   12 ++++++++++++
 1 files changed, 12 insertions(+), 0 deletions(-)
---
diff --git a/glib/gdatetime.c b/glib/gdatetime.c
index 32e280f..cd44ef2 100644
--- a/glib/gdatetime.c
+++ b/glib/gdatetime.c
@@ -53,6 +53,7 @@
 #ifdef HAVE_UNISTD_H
 #include <unistd.h>
 #endif
+#include <langinfo.h>
 
 #include "gdatetime.h"
 
@@ -2222,6 +2223,11 @@ get_numeric_format (gchar    *fmt,
  *    a tab character
  *  </simpara></listitem></varlistentry>
  *  <varlistentry><term>
+ *    <literal>%%T</literal>:
+ *   </term><listitem><simpara>
+ *    the time in 24-hour notation with seconds (<literal>%%H:%%M:%%S</literal>)
+ *  </simpara></listitem></varlistentry>
+ *  <varlistentry><term>
  *    <literal>%%u</literal>:
  *   </term><listitem><simpara>
  *    the day of the week as a decimal, range 1 to 7, Monday being 1
@@ -2457,6 +2463,12 @@ g_date_time_format (GDateTime *datetime,
                 case 't':
                   g_string_append_c (outstr, '\t');
                   break;
+                case 'T':
+                  g_string_append_printf (outstr, "%02d:%02d:%02d",
+                                          g_date_time_get_hour (datetime),
+                                          g_date_time_get_minute (datetime),
+                                          g_date_time_get_second (datetime));
+                  break;
                 case 'u':
                   get_numeric_format (fmt, sizeof(fmt), alt_digits, 0, 0);
                   g_string_append_printf (outstr, fmt, g_date_time_get_day_of_week (datetime));



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