From 8db52a536d451e742582f22dd7c9f827447e3fca Mon Sep 17 00:00:00 2001 From: Emilio Pozuelo Monfort Date: Tue, 8 Mar 2016 16:42:13 +0100 Subject: where-am-i: Show location timestamp If available. https://bugs.freedesktop.org/show_bug.cgi?id=94157 --- demo/where-am-i.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'demo') diff --git a/demo/where-am-i.c b/demo/where-am-i.c index d9aeb2a..f9c847d 100644 --- a/demo/where-am-i.c +++ b/demo/where-am-i.c @@ -74,6 +74,8 @@ print_location (GClueSimple *simple) { GClueLocation *location; gdouble altitude, speed, heading; + GVariant *timestamp; + GTimeVal tv = { 0 }; const char *desc; location = gclue_simple_get_location (simple); @@ -96,6 +98,24 @@ print_location (GClueSimple *simple) desc = gclue_location_get_description (location); if (strlen (desc) > 0) g_print ("Description: %s\n", desc); + + timestamp = gclue_location_get_timestamp (location); + if (timestamp) { + GDateTime *date_time; + gchar *str; + + g_variant_get (timestamp, "(tt)", &tv.tv_sec, &tv.tv_usec); + g_variant_unref (timestamp); + + date_time = g_date_time_new_from_timeval_local (&tv); + str = g_date_time_format + (date_time, + "%c (%s seconds since the Epoch)"); + g_date_time_unref (date_time); + + g_print ("Timestamp: %s\n", str); + g_free (str); + } } static void -- cgit v1.2.1