Commit 6688fbdb authored by Sean Davis's avatar Sean Davis 🕶

Reimplement g_date_time_format_iso8601 to drop GLib support from 2.62 to 2.50

parent 8226d00f
......@@ -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,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment