From a944f4d1af2ac360a66074cf9339c1139775b99d Mon Sep 17 00:00:00 2001 From: Kenneth Heitke Date: Fri, 5 Apr 2019 12:18:30 -0600 Subject: [PATCH] Print timestamp as a date and time string Signed-off-by: Kenneth Heitke --- nvme-print.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/nvme-print.c b/nvme-print.c index 14276824..cfe88e3b 100644 --- a/nvme-print.c +++ b/nvme-print.c @@ -1,6 +1,7 @@ #include #include #include +#include #include "nvme-print.h" #include "json.h" @@ -1845,7 +1846,14 @@ static void show_auto_pst(struct nvme_auto_pst *apst) static void show_timestamp(struct nvme_timestamp *ts) { - printf("\tThe timestamp is : %"PRIu64"\n", int48_to_long(ts->timestamp)); + struct tm *tm; + char buffer[32]; + time_t timestamp = int48_to_long(ts->timestamp) / 1000; + + tm = localtime(×tamp); + strftime(buffer, sizeof(buffer), "%c %Z", tm); + + printf("\tThe timestamp is : %"PRIu64" (%s)\n", int48_to_long(ts->timestamp), buffer); printf("\t%s\n", (ts->attr & 2) ? "The Timestamp field was initialized with a "\ "Timestamp value using a Set Features command." : "The Timestamp field was initialized "\ "to ‘0’ by a Controller Level Reset."); -- 2.50.1