diff options
author | Richard Hughes <richard@hughsie.com> | 2016-07-19 15:46:11 +0100 |
---|---|---|
committer | Richard Hughes <richard@hughsie.com> | 2016-07-20 16:35:39 +0100 |
commit | 783692c5b379c2d0ad5a5c4bd50f29f5652a9f1c (patch) | |
tree | 726d792148cf127a39626510c2a2465b45847f83 /libappstream-glib/as-release.c | |
parent | 0c5326ea06054bcd95d43476ea4b08023affba35 (diff) | |
download | appstream-glib-783692c5b379c2d0ad5a5c4bd50f29f5652a9f1c.tar.gz |
trivial: Factor out a soon-to-be-shared function
Diffstat (limited to 'libappstream-glib/as-release.c')
-rw-r--r-- | libappstream-glib/as-release.c | 28 |
1 files changed, 1 insertions, 27 deletions
diff --git a/libappstream-glib/as-release.c b/libappstream-glib/as-release.c index 731daa1..b273078 100644 --- a/libappstream-glib/as-release.c +++ b/libappstream-glib/as-release.c @@ -603,32 +603,6 @@ as_release_node_insert (AsRelease *release, GNode *parent, AsNodeContext *ctx) return n; } -static GDateTime * -as_release_iso8601_to_datetime (const gchar *iso_date) -{ - GTimeVal tv; - guint dmy[] = {0, 0, 0}; - - /* nothing set */ - if (iso_date == NULL || iso_date[0] == '\0') - return NULL; - - /* try to parse complete ISO8601 date */ - if (g_strstr_len (iso_date, -1, " ") != NULL) { - if (g_time_val_from_iso8601 (iso_date, &tv) && tv.tv_sec != 0) - return g_date_time_new_from_timeval_utc (&tv); - } - - /* g_time_val_from_iso8601() blows goats and won't - * accept a valid ISO8601 formatted date without a - * time value - try and parse this case */ - if (sscanf (iso_date, "%u-%u-%u", &dmy[0], &dmy[1], &dmy[2]) != 3) - return NULL; - - /* create valid object */ - return g_date_time_new_utc (dmy[0], dmy[1], dmy[2], 0, 0, 0); -} - /** * as_release_node_parse: * @release: a #AsRelease instance. @@ -656,7 +630,7 @@ as_release_node_parse (AsRelease *release, GNode *node, tmp = as_node_get_attribute (node, "date"); if (tmp != NULL) { g_autoptr(GDateTime) dt = NULL; - dt = as_release_iso8601_to_datetime (tmp); + dt = as_utils_iso8601_to_datetime (tmp); if (dt != NULL) as_release_set_timestamp (release, g_date_time_to_unix (dt)); } |