[balsa] rfc2445: Use GDateTime instead of GTimeVal



commit b9f1e89d8f7889ae7730d6654c2648fe59fef2c2
Author: Peter Bloomfield <PeterBloomfield bellsouth net>
Date:   Mon Jul 29 11:48:13 2019 -0400

    rfc2445: Use GDateTime instead of GTimeVal
    
    Use GDateTime instead of GTimeVal, if the glib version is at least 2.56;
    GTimeVal is deprecated in glib version 2.62.
    
    * libbalsa/rfc2445.c (date_time_2445_to_time_t):

 ChangeLog          |  7 +++++++
 libbalsa/rfc2445.c | 13 +++++++++++++
 2 files changed, 20 insertions(+)
---
diff --git a/ChangeLog b/ChangeLog
index 2e5e37170..a2ba653dd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2019-07-29  Peter Bloomfield  <pbloomfield bellsouth net>
+
+       rfc2445: Use GDateTime instead of GTimeVal, which is deprecated
+       in glib version 2.62.
+
+       * libbalsa/rfc2445.c (date_time_2445_to_time_t):
+
 2019-07-29  Peter Bloomfield  <pbloomfield bellsouth net>
 
        main-window: declare it derivable
diff --git a/libbalsa/rfc2445.c b/libbalsa/rfc2445.c
index fa0967ed5..5f4f7f19a 100644
--- a/libbalsa/rfc2445.c
+++ b/libbalsa/rfc2445.c
@@ -614,6 +614,18 @@ date_time_2445_to_time_t(const gchar *date_time, const gchar *modifier, gboolean
     /* must be yyyymmddThhmmssZ? */
     if (((len == 15) || ((len == 16) && (date_time[15] == 'Z'))) &&
        (date_time[8] == 'T')) {
+#if GLIB_CHECK_VERSION(2, 56, 0)
+        GDateTime *datetime;
+
+        datetime = g_date_time_new_from_iso8601(date_time, NULL);
+        if (datetime != NULL) {
+            the_time = g_date_time_to_unix(datetime);
+            if (date_only != NULL) {
+                *date_only = FALSE;
+            }
+            g_date_time_unref(datetime);
+        }
+#else /* GLIB_CHECK_VERSION(2, 56, 0) */
         GTimeVal timeval;
 
         /* the rfc2445 date-time is a special case of an iso8901 date/time value... */
@@ -623,6 +635,7 @@ date_time_2445_to_time_t(const gchar *date_time, const gchar *modifier, gboolean
                        *date_only = FALSE;
                }
         }
+#endif /* GLIB_CHECK_VERSION(2, 56, 0) */
     } else if ((modifier!= NULL) && (g_ascii_strcasecmp(modifier, "VALUE=DATE") == 0) && (len == 8)) {
        struct tm tm;
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]