summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVictor Toso <me@victortoso.com>2020-02-17 17:30:03 +0100
committerVictor Toso <me@victortoso.com>2020-02-21 11:39:02 +0100
commit0907a4cd3257bfd29ec179a607fbe00166a005f3 (patch)
treedaca885936f25db59e69042c7c7884eb1c3f40f6
parente0488fda3239aef4e0963007768860d4861fffd1 (diff)
downloadgrilo-0907a4cd3257bfd29ec179a607fbe00166a005f3.tar.gz
core: remove GTimeVal from grl_date_time_from_iso8601()
This patch makes usage of g_date_time_new_from_iso8601() from GLib 2.56 that returns GDateTime* from ISO 8601 formatted string. Note that this API supported a little bit more than GLib's as a helper while developing new plugins thus it makes sense to keep it around.
-rw-r--r--src/grl-util.c21
1 files changed, 10 insertions, 11 deletions
diff --git a/src/grl-util.c b/src/grl-util.c
index 27afbc8..067d2ac 100644
--- a/src/grl-util.c
+++ b/src/grl-util.c
@@ -26,6 +26,7 @@
*/
#include "grl-util.h"
+#include "grl-log.h"
#include <string.h>
@@ -145,8 +146,7 @@ grl_list_from_va (gpointer p, ...)
GDateTime *
grl_date_time_from_iso8601 (const gchar *date)
{
- GTimeVal t = { 0, };
- gboolean ret;
+ GDateTime *converted;
gchar *date_time;
gint date_length;
@@ -154,11 +154,9 @@ grl_date_time_from_iso8601 (const gchar *date)
return NULL;
}
- ret = g_time_val_from_iso8601 (date, &t);
+ converted = g_date_time_new_from_iso8601 (date, NULL);
+ if (converted == NULL) {
- /* second condition works around
- * https://bugzilla.gnome.org/show_bug.cgi?id=650968 */
- if (!ret || (t.tv_sec == 0 && t.tv_usec == 0)) {
/* We might be in the case where there is a date alone. In that case, we
* take the convention of setting it to noon GMT */
@@ -174,13 +172,14 @@ grl_date_time_from_iso8601 (const gchar *date)
default:
date_time = g_strdup_printf ("%sT12:00:00Z", date);
}
- ret = g_time_val_from_iso8601 (date_time, &t);
+ converted = g_date_time_new_from_iso8601 (date_time, NULL);
+
+ if (converted == NULL)
+ GRL_DEBUG ("Failed to convert %s and %s to ISO8601", date, date_time);
+
g_free (date_time);
}
- if (ret)
- return g_date_time_new_from_timeval_utc (&t);
-
- return NULL;
+ return converted;
}