[Xfce4-commits] [apps/xfce4-screensaver] 01/01: Reimplement g_date_time_format_iso8601 to drop GLib support from 2.62 to 2.50

noreply at xfce.org noreply at xfce.org
Mon Mar 23 00:38:01 CET 2020


This is an automated email from the git hooks/post-receive script.

b   l   u   e   s   a   b   r   e       p   u   s   h   e   d       a       c   o   m   m   i   t       t   o       b   r   a   n   c   h       m   a   s   t   e   r   
   in repository apps/xfce4-screensaver.

commit 6688fbdb300d8daa45f500b891c422e27aad54a0
Author: Sean Davis <smd.seandavis at gmail.com>
Date:   Sun Mar 22 19:37:55 2020 -0400

    Reimplement g_date_time_format_iso8601 to drop GLib support from 2.62 to 2.50
---
 src/gs-listener-dbus.c | 38 +++++++++++++++++++++++++++++++++++++-
 1 file changed, 37 insertions(+), 1 deletion(-)

diff --git a/src/gs-listener-dbus.c b/src/gs-listener-dbus.c
index 66b112a..3463ef9 100644
--- a/src/gs-listener-dbus.c
+++ b/src/gs-listener-dbus.c
@@ -703,6 +703,42 @@ out:
     return removed;
 }
 
+/**
+ * Borrowed from https://gitlab.gnome.org/GNOME/glib/blob/master/glib/gdatetime.c
+ * g_date_time_format_iso8601 is not available until 2.62, but we support 2.50+
+ * LGPL 2.1+
+ */
+static gchar *
+listener_g_date_time_format_iso8601 (GDateTime *datetime)
+{
+  GString *outstr = NULL;
+  gchar *main_date = NULL;
+  gint64 offset;
+
+  /* Main date and time. */
+  main_date = g_date_time_format (datetime, "%Y-%m-%dT%H:%M:%S");
+  outstr = g_string_new (main_date);
+  g_free (main_date);
+
+  /* Timezone. Format it as `%:::z` unless the offset is zero, in which case
+   * we can simply use `Z`. */
+  offset = g_date_time_get_utc_offset (datetime);
+
+  if (offset == 0)
+    {
+      g_string_append_c (outstr, 'Z');
+    }
+  else
+    {
+      gchar *time_zone = g_date_time_format (datetime, "%:::z");
+      g_string_append (outstr, time_zone);
+      g_free (time_zone);
+    }
+
+  return g_string_free (outstr, FALSE);
+}
+
+
 static void
 accumulate_ref_entry (gpointer            key,
                       GSListenerRefEntry *entry,
@@ -710,7 +746,7 @@ accumulate_ref_entry (gpointer            key,
     char *description;
     char *time;
 
-    time = g_date_time_format_iso8601 (entry->since);
+    time = listener_g_date_time_format_iso8601 (entry->since);
 
     description = g_strdup_printf ("Application=\"%s\"; Since=\"%s\"; Reason=\"%s\";",
                                    entry->application,

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Xfce4-commits mailing list