aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@aleksander.es>2015-02-04 18:54:32 +0100
committerAleksander Morgado <aleksander@aleksander.es>2015-02-04 18:54:45 +0100
commit7c5965baab419c984fea33bf321bcb1622e484f4 (patch)
treea3b594fcf7cc8492d59dff859f7734e2ac92dd9c /src
parent9f7cd9f9b244e2454db652d637e3f9ac2022cf9d (diff)
qmicli: in '--dms-get-time' print date/time along with the gpstime epoch
Diffstat (limited to 'src')
-rw-r--r--src/qmicli/qmicli-dms.c35
1 files changed, 29 insertions, 6 deletions
diff --git a/src/qmicli/qmicli-dms.c b/src/qmicli/qmicli-dms.c
index 0ad64a6..e529cba 100644
--- a/src/qmicli/qmicli-dms.c
+++ b/src/qmicli/qmicli-dms.c
@@ -1575,6 +1575,10 @@ get_time_ready (QmiClientDms *client,
guint64 time_count;
QmiDmsTimeSource time_source;
GError *error = NULL;
+ gchar *str;
+ GTimeZone *timezone;
+ GDateTime *gpstime_epoch;
+ GDateTime *computed_epoch;
output = qmi_client_dms_get_time_finish (client, res, &error);
if (!output) {
@@ -1598,29 +1602,48 @@ get_time_ready (QmiClientDms *client,
&time_source,
NULL);
+ /* January 6th 1980 */
+ timezone = g_time_zone_new_utc ();
+ gpstime_epoch = g_date_time_new (timezone, 1980, 1, 6, 0, 0, 0.0);
+
+ computed_epoch = g_date_time_add_seconds (gpstime_epoch, ((gdouble) time_count / 1000.0));
+ str = g_date_time_format (computed_epoch, "%F %T");
g_print ("[%s] Time retrieved:\n"
- "\tTime count: '%" G_GUINT64_FORMAT " (x 1.25ms)'\n"
+ "\tTime count: '%" G_GUINT64_FORMAT " (x 1.25ms): %s'\n"
"\tTime source: '%s'\n",
qmi_device_get_path_display (ctx->device),
- time_count,
+ time_count, str,
qmi_dms_time_source_get_string (time_source));
+ g_free (str);
+ g_date_time_unref (computed_epoch);
if (qmi_message_dms_get_time_output_get_system_time (
output,
&time_count,
NULL)){
- g_print ("\tSystem time: '%" G_GUINT64_FORMAT " (ms)'\n",
- time_count);
+ computed_epoch = g_date_time_add_seconds (gpstime_epoch, ((gdouble) time_count / 1000.0));
+ str = g_date_time_format (computed_epoch, "%F %T");
+ g_print ("\tSystem time: '%" G_GUINT64_FORMAT " (ms): %s'\n",
+ time_count, str);
+ g_free (str);
+ g_date_time_unref (computed_epoch);
}
if (qmi_message_dms_get_time_output_get_user_time (
output,
&time_count,
NULL)){
- g_print ("\tUser time: '%" G_GUINT64_FORMAT " (ms)'\n",
- time_count);
+ computed_epoch = g_date_time_add_seconds (gpstime_epoch, ((gdouble) time_count / 1000.0));
+ str = g_date_time_format (computed_epoch, "%F %T");
+ g_print ("\tUser time: '%" G_GUINT64_FORMAT " (ms): %s'\n",
+ time_count, str);
+ g_free (str);
+ g_date_time_unref (computed_epoch);
}
+ g_date_time_unref (gpstime_epoch);
+ g_time_zone_unref (timezone);
+
qmi_message_dms_get_time_output_unref (output);
shutdown (TRUE);
}