[PATCH] Add output of local time when adding the option of "--pretty" for virsh domtime

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Add more human-friendly output of domain's system time.

Signed-off-by: ZhiPeng Lu <lu.zhipeng@xxxxxxxxxx>
Reviewed-by: Jiyun Fan <fan.jiyun@xxxxxxxxxx>
---
 tools/virsh-domain-monitor.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/tools/virsh-domain-monitor.c b/tools/virsh-domain-monitor.c
index 35d04b2..d9520ff 100644
--- a/tools/virsh-domain-monitor.c
+++ b/tools/virsh-domain-monitor.c
@@ -1384,17 +1384,22 @@ cmdDomTime(vshControl *ctl, const vshCmd *cmd)
             goto cleanup;
 
         if (pretty) {
-            char timestr[100];
+            char timestr[100], localtimestr[100];
             time_t cur_time = seconds;
-            struct tm time_info;
+            struct tm time_info, local_time_info;
 
             if (!gmtime_r(&cur_time, &time_info)) {
                 vshError(ctl, _("Unable to format time"));
                 goto cleanup;
             }
+            if (!localtime_r(&cur_time, &local_time_info)) {
+                vshError(ctl, _("Unable to format local time"));
+                goto cleanup;
+            }
             strftime(timestr, sizeof(timestr), "%Y-%m-%d %H:%M:%S", &time_info);
+            strftime(localtimestr, sizeof(localtimestr), "%Y-%m-%d %H:%M:%S", &local_time_info);
 
-            vshPrint(ctl, _("Time: %s"), timestr);
+            vshPrint(ctl, _("Time: %s\n Local time: %s"), timestr, localtimestr);
         } else {
             vshPrint(ctl, _("Time: %lld"), seconds);
         }
-- 
1.8.3.1

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]
  Powered by Linux