From: Matthew Leeds <matthew.leeds@endlessm.com>
Date: Sun, 22 Mar 2020 14:45:51 -0700
Subject: Fix deprecation warnings for use of GTimeVal

Only 18 years left until this would have been an issue

(cherry picked from commit e80b4dcfd85f8eab1e2becee7738849bf5601ca7)
---
 meson.build           |  6 +++---
 src/gr-image.c        | 15 ++++++---------
 src/gr-recipe-store.c | 15 ++++++---------
 3 files changed, 15 insertions(+), 21 deletions(-)

diff --git a/meson.build b/meson.build
index 329b5cb..cd1ab70 100644
--- a/meson.build
+++ b/meson.build
@@ -81,9 +81,9 @@ if get_option('canberra') != 'no'
 endif
 
 deps = [ dependency('gtk+-3.0', version : '>=3.22'),
-         dependency('glib-2.0'),
-         dependency('gio-2.0'),
-         dependency('gio-unix-2.0'),
+         dependency('glib-2.0', version : '>= 2.61.2'),
+         dependency('gio-2.0', version : '>= 2.61.2'),
+         dependency('gio-unix-2.0', version : '>= 2.61.2'),
          dependency('gmodule-export-2.0'),
          dependency('libsoup-3.0'),
          dependency('goa-1.0'),
diff --git a/src/gr-image.c b/src/gr-image.c
index 42d704a..ba2b459 100644
--- a/src/gr-image.c
+++ b/src/gr-image.c
@@ -238,17 +238,15 @@ should_try_load (const char *path)
                                   G_FILE_QUERY_INFO_NONE,
                                   NULL,
                                   NULL);
-        if (info) {
+        if (info &&
+            g_file_info_has_attribute (info, G_FILE_ATTRIBUTE_TIME_MODIFIED)) {
                 goffset size;
-                GTimeVal tv;
                 g_autoptr(GDateTime) now = NULL;
                 g_autoptr(GDateTime) mtime = NULL;
 
                 size = g_file_info_get_size (info);
-                g_file_info_get_modification_time (info, &tv);
-
                 now = g_date_time_new_now_utc ();
-                mtime = g_date_time_new_from_timeval_utc (&tv);
+                mtime = g_file_info_get_modification_date_time (info);
 
                 if (size == 6) {
                         result = g_date_time_difference (now, mtime) > G_TIME_SPAN_DAY;
@@ -300,13 +298,12 @@ set_modified_request (SoupMessage *msg,
                                   G_FILE_QUERY_INFO_NONE,
                                   NULL,
                                   NULL);
-        if (info) {
-                GTimeVal tv;
+        if (info &&
+            g_file_info_has_attribute (info, G_FILE_ATTRIBUTE_TIME_MODIFIED)) {
                 g_autoptr(GDateTime) mtime = NULL;
                 g_autofree char *mod_date = NULL;
 
-                g_file_info_get_modification_time (info, &tv);
-                mtime = g_date_time_new_from_timeval_utc (&tv);
+                mtime = g_file_info_get_modification_date_time (info);
                 mod_date = g_date_time_format (mtime, "%a, %d %b %Y %H:%M:%S %Z");
                 soup_message_headers_append (soup_message_get_request_headers (msg), "If-Modified-Since", mod_date);
         }
diff --git a/src/gr-recipe-store.c b/src/gr-recipe-store.c
index d63a170..e5de121 100644
--- a/src/gr-recipe-store.c
+++ b/src/gr-recipe-store.c
@@ -991,15 +991,13 @@ should_try_load (const char *path)
                                   G_FILE_QUERY_INFO_NONE,
                                   NULL,
                                   NULL);
-        if (info) {
-                GTimeVal tv;
+        if (info &&
+            g_file_info_has_attribute (info, G_FILE_ATTRIBUTE_TIME_MODIFIED)) {
                 g_autoptr(GDateTime) now = NULL;
                 g_autoptr(GDateTime) mtime = NULL;
 
-                g_file_info_get_modification_time (info, &tv);
-
                 now = g_date_time_new_now_utc ();
-                mtime = g_date_time_new_from_timeval_utc (&tv);
+                mtime = g_file_info_get_modification_date_time (info);
 
                 result = g_date_time_difference (now, mtime) > G_TIME_SPAN_DAY;
                 g_debug ("Cached file for %s is %s",
@@ -1016,7 +1014,6 @@ set_modified_request (SoupMessage *msg,
 {
         g_autoptr(GFile) file = NULL;
         g_autoptr(GFileInfo) info = NULL;
-        GTimeVal tv;
         g_autoptr(GDateTime) mtime = NULL;
         g_autofree char *mod_date = NULL;
 
@@ -1027,9 +1024,9 @@ set_modified_request (SoupMessage *msg,
                                   NULL,
                                   NULL);
 
-        if (info) {
-                g_file_info_get_modification_time (info, &tv);
-                mtime = g_date_time_new_from_timeval_utc (&tv);
+        if (info &&
+            g_file_info_has_attribute (info, G_FILE_ATTRIBUTE_TIME_MODIFIED)) {
+                mtime = g_file_info_get_modification_date_time (info);
                 mod_date = g_date_time_format (mtime, "%a, %d %b %Y %H:%M:%S %Z");
                 soup_message_headers_append (soup_message_get_request_headers (msg), "If-Modified-Since", mod_date);
         }
