Commit c7323d69 authored by Matthias Klumpp's avatar Matthias Klumpp
Browse files

Reduce minimum required GLib version to 2.58

Makes the life of backporters easier. This is the version used by latest
Debian stable (buster) so it's a reasonable target.
parent cb9373cf
...@@ -60,10 +60,10 @@ add_global_arguments('-DAS_COMPILATION', language : 'c') ...@@ -60,10 +60,10 @@ add_global_arguments('-DAS_COMPILATION', language : 'c')
# #
# Dependencies # Dependencies
# #
glib_dep = dependency('glib-2.0', version: '>=2.62') glib_dep = dependency('glib-2.0', version: '>=2.58')
gobject_dep = dependency('gobject-2.0', version: '>=2.62') gobject_dep = dependency('gobject-2.0', version: '>=2.58')
gio_dep = dependency('gio-2.0', version: '>=2.62') gio_dep = dependency('gio-2.0', version: '>=2.58')
gio_unix_dep = dependency('gio-unix-2.0', version: '>=2.62') gio_unix_dep = dependency('gio-unix-2.0', version: '>=2.58')
soup_dep = dependency('libsoup-2.4', version: '>= 2.56') soup_dep = dependency('libsoup-2.4', version: '>= 2.56')
xml2_dep = dependency('libxml-2.0') xml2_dep = dependency('libxml-2.0')
yaml_dep = dependency('yaml-0.1') yaml_dep = dependency('yaml-0.1')
......
...@@ -303,7 +303,7 @@ as_release_set_timestamp (AsRelease *release, guint64 timestamp) ...@@ -303,7 +303,7 @@ as_release_set_timestamp (AsRelease *release, guint64 timestamp)
priv->timestamp = timestamp; priv->timestamp = timestamp;
g_free (priv->date); g_free (priv->date);
priv->date = g_date_time_format_iso8601 (time); priv->date = as_date_time_format_iso8601 (time);
} }
/** /**
...@@ -434,7 +434,7 @@ as_release_set_timestamp_eol (AsRelease *release, guint64 timestamp) ...@@ -434,7 +434,7 @@ as_release_set_timestamp_eol (AsRelease *release, guint64 timestamp)
time = g_date_time_new_from_unix_utc (timestamp); time = g_date_time_new_from_unix_utc (timestamp);
g_free (priv->date_eol); g_free (priv->date_eol);
priv->date_eol = g_date_time_format_iso8601 (time); priv->date_eol = as_date_time_format_iso8601 (time);
} }
/** /**
...@@ -1021,7 +1021,7 @@ as_release_to_xml_node (AsRelease *release, AsContext *ctx, xmlNode *root) ...@@ -1021,7 +1021,7 @@ as_release_to_xml_node (AsRelease *release, AsContext *ctx, xmlNode *root)
(xmlChar*) time_str); (xmlChar*) time_str);
} else { } else {
g_autoptr(GDateTime) time = g_date_time_new_from_unix_utc (priv->timestamp); g_autoptr(GDateTime) time = g_date_time_new_from_unix_utc (priv->timestamp);
time_str = g_date_time_format_iso8601 (time); time_str = as_date_time_format_iso8601 (time);
xmlNewProp (subnode, (xmlChar*) "date", xmlNewProp (subnode, (xmlChar*) "date",
(xmlChar*) time_str); (xmlChar*) time_str);
} }
...@@ -1168,7 +1168,7 @@ as_release_emit_yaml (AsRelease *release, AsContext *ctx, yaml_emitter_t *emitte ...@@ -1168,7 +1168,7 @@ as_release_emit_yaml (AsRelease *release, AsContext *ctx, yaml_emitter_t *emitte
priv->timestamp); priv->timestamp);
} else { } else {
g_autoptr(GDateTime) time = g_date_time_new_from_unix_utc (priv->timestamp); g_autoptr(GDateTime) time = g_date_time_new_from_unix_utc (priv->timestamp);
time_str = g_date_time_format_iso8601 (time); time_str = as_date_time_format_iso8601 (time);
as_yaml_emit_entry (emitter, "date", time_str); as_yaml_emit_entry (emitter, "date", time_str);
} }
} }
......
...@@ -128,6 +128,8 @@ gchar *as_ptr_array_to_str (GPtrArray *array, ...@@ -128,6 +128,8 @@ gchar *as_ptr_array_to_str (GPtrArray *array,
AS_INTERNAL_VISIBLE AS_INTERNAL_VISIBLE
gchar *as_filebasename_from_uri (const gchar *uri); gchar *as_filebasename_from_uri (const gchar *uri);
gchar *as_date_time_format_iso8601 (GDateTime *datetime);
#pragma GCC visibility pop #pragma GCC visibility pop
G_END_DECLS G_END_DECLS
......
...@@ -1391,3 +1391,43 @@ as_filebasename_from_uri (const gchar *uri) ...@@ -1391,3 +1391,43 @@ as_filebasename_from_uri (const gchar *uri)
return bname; return bname;
} }
/**
* as_date_time_format_iso8601:
* @datetime: A #GDateTime
*
* Format datetime in ISO 8601 format.
*
* Compatibility wrapper to support GLib < 2.62.
* This function can go away if we bump the GLib minimal version.
*/
gchar*
as_date_time_format_iso8601 (GDateTime *datetime)
{
#if GLIB_CHECK_VERSION(2,62,0)
return g_date_time_format_iso8601 (datetime);
#else
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);
#endif
}
Supports Markdown
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