summaryrefslogtreecommitdiff
path: root/demo
diff options
context:
space:
mode:
authorEmilio Pozuelo Monfort <emilio.pozuelo@collabora.co.uk>2016-03-08 16:42:13 +0100
committerZeeshan Ali (Khattak) <zeeshanak@gnome.org>2016-04-20 18:40:41 +0100
commit8db52a536d451e742582f22dd7c9f827447e3fca (patch)
tree33d6e4a2ff2332c044b4e5375f1bff5c99d62b60 /demo
parent104ab575078812c012eadd983d905c6a0f0fea04 (diff)
downloadgeoclue-8db52a536d451e742582f22dd7c9f827447e3fca.tar.gz
where-am-i: Show location timestamp
If available. https://bugs.freedesktop.org/show_bug.cgi?id=94157
Diffstat (limited to 'demo')
-rw-r--r--demo/where-am-i.c20
1 files changed, 20 insertions, 0 deletions
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