[gnome-photos/sam/tracker3: 14/15] Use GDateTime instead of deprecated GTimeVal
- From: Sam Thursfield <sthursfield src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-photos/sam/tracker3: 14/15] Use GDateTime instead of deprecated GTimeVal
- Date: Mon, 8 Jun 2020 11:14:45 +0000 (UTC)
commit e962d28081f33fbead6046da9f968e6780f479c6
Author: Sam Thursfield <sam afuera me uk>
Date: Mon Jun 8 12:13:59 2020 +0200
Use GDateTime instead of deprecated GTimeVal
Dates are stored in UTC time zone.
FIXME: does this make sense?
meson.build | 2 +-
src/photos-query-builder.c | 18 ++++++------------
2 files changed, 7 insertions(+), 13 deletions(-)
---
diff --git a/meson.build b/meson.build
index 227f6192..42384a61 100644
--- a/meson.build
+++ b/meson.build
@@ -157,7 +157,7 @@ geocode_glib_dep = dependency('geocode-glib-1.0')
gexiv_dep = dependency('gexiv2', version: '>= 0.10.8')
gio_dep = dependency('gio-2.0')
gio_unix_dep = dependency('gio-unix-2.0')
-glib_dep = dependency('glib-2.0', version: '>= 2.57.2')
+glib_dep = dependency('glib-2.0', version: '>= 2.62.0')
goa_dep = dependency('goa-1.0', version: '>= 3.8.0')
config_h.set('GOA_API_IS_SUBJECT_TO_CHANGE', true)
diff --git a/src/photos-query-builder.c b/src/photos-query-builder.c
index 5d9d8a5a..a614d82f 100644
--- a/src/photos-query-builder.c
+++ b/src/photos-query-builder.c
@@ -131,21 +131,18 @@ photos_query_builder_create_collection_query (PhotosSearchContextState *state,
const gchar *name,
const gchar *identifier_tag)
{
- GTimeVal tv;
PhotosQuery *query;
g_autofree gchar *identifier = NULL;
g_autofree gchar *sparql = NULL;
+ g_autoptr (GDateTime) datetime = NULL;
g_autofree gchar *time = NULL;
- gint64 timestamp;
identifier = g_strdup_printf ("%s%s",
PHOTOS_QUERY_LOCAL_COLLECTIONS_IDENTIFIER,
identifier_tag == NULL ? name : identifier_tag);
- timestamp = g_get_real_time () / G_USEC_PER_SEC;
- tv.tv_sec = timestamp;
- tv.tv_usec = 0;
- time = g_time_val_to_iso8601 (&tv);
+ datetime = g_date_time_new_now_utc ();
+ time = g_date_time_format_iso8601 (datetime);
sparql = g_strdup_printf ("INSERT { _:res a nfo:DataContainer ; a nie:DataObject ; "
"nie:contentLastModified '%s' ; "
@@ -349,16 +346,13 @@ photos_query_builder_single_query (PhotosSearchContextState *state, gint flags,
PhotosQuery *
photos_query_builder_update_mtime_query (PhotosSearchContextState *state, const gchar *resource)
{
- GTimeVal tv;
PhotosQuery *query;
g_autofree gchar *sparql = NULL;
+ g_autoptr (GDateTime) datetime = NULL;
g_autofree gchar *time = NULL;
- gint64 timestamp;
- timestamp = g_get_real_time () / G_USEC_PER_SEC;
- tv.tv_sec = timestamp;
- tv.tv_usec = 0;
- time = g_time_val_to_iso8601 (&tv);
+ datetime = g_date_time_new_now_utc ();
+ time = g_date_time_format_iso8601 (datetime);
sparql = g_strdup_printf ("INSERT OR REPLACE { <%s> nie:contentLastModified '%s' }", resource, time);
query = photos_query_new (state, sparql);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]