about summary refs log tree commit diff stats
path: root/src/xmpp/stanza.c
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2015-06-29 23:48:41 +0100
committerJames Booth <boothj5@gmail.com>2015-06-29 23:48:41 +0100
commitdd206ef637e8f29d5b78f2b72ff27badaec1b14e (patch)
treedb48946e6561c1d4633f21cda8a7b771b46c2cb9 /src/xmpp/stanza.c
parentfed55b5459902acdd10e5aa481bd54f00ad4c97e (diff)
downloadprofani-tty-dd206ef637e8f29d5b78f2b72ff27badaec1b14e.tar.gz
WIP fix for #516, needs memory cleanup
Diffstat (limited to 'src/xmpp/stanza.c')
-rw-r--r--src/xmpp/stanza.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/src/xmpp/stanza.c b/src/xmpp/stanza.c
index 1f25239b..4999c81b 100644
--- a/src/xmpp/stanza.c
+++ b/src/xmpp/stanza.c
@@ -982,17 +982,20 @@ stanza_create_ping_iq(xmpp_ctx_t *ctx, const char * const target)
     return iq;
 }
 
-gboolean
-stanza_get_delay(xmpp_stanza_t * const stanza, GTimeVal *tv_stamp)
+GDateTime*
+stanza_get_delay(xmpp_stanza_t * const stanza)
 {
+    GTimeVal utc_stamp;
     // first check for XEP-0203 delayed delivery
     xmpp_stanza_t *delay = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_DELAY);
     if (delay) {
         char *xmlns = xmpp_stanza_get_attribute(delay, STANZA_ATTR_XMLNS);
         if (xmlns && (strcmp(xmlns, "urn:xmpp:delay") == 0)) {
             char *stamp = xmpp_stanza_get_attribute(delay, STANZA_ATTR_STAMP);
-            if (stamp && (g_time_val_from_iso8601(stamp, tv_stamp))) {
-                return TRUE;
+            if (stamp && (g_time_val_from_iso8601(stamp, &utc_stamp))) {
+                GDateTime *utc_datetime = g_date_time_new_from_timeval_utc(&utc_stamp);
+                GDateTime *local_datetime = g_date_time_to_local(utc_datetime);
+                return local_datetime;
             }
         }
     }
@@ -1004,13 +1007,15 @@ stanza_get_delay(xmpp_stanza_t * const stanza, GTimeVal *tv_stamp)
         char *xmlns = xmpp_stanza_get_attribute(x, STANZA_ATTR_XMLNS);
         if (xmlns && (strcmp(xmlns, "jabber:x:delay") == 0)) {
             char *stamp = xmpp_stanza_get_attribute(x, STANZA_ATTR_STAMP);
-            if (stamp && (g_time_val_from_iso8601(stamp, tv_stamp))) {
-                return TRUE;
+            if (stamp && (g_time_val_from_iso8601(stamp, &utc_stamp))) {
+                GDateTime *utc_datetime = g_date_time_new_from_timeval_utc(&utc_stamp);
+                GDateTime *local_datetime = g_date_time_to_local(utc_datetime);
+                return local_datetime;
             }
         }
     }
 
-    return FALSE;
+    return NULL;
 }
 
 char *