]> git.proxmox.com Git - mirror_frr.git/blobdiff - isisd/isis_vty_fabricd.c
lib, *: add a common time interval formatting api
[mirror_frr.git] / isisd / isis_vty_fabricd.c
index 88f7337a913e3e7bd46c7079fe6d3b6f175cf0e9..09b8d2825842407429c0e4b22cb72ae182d4ef1b 100644 (file)
@@ -115,6 +115,7 @@ DEFUN (no_triggered_csnp,
 static void lsp_print_flooding(struct vty *vty, struct isis_lsp *lsp)
 {
        char lspid[255];
+       char buf[MONOTIME_STRLEN];
 
        lspid_print(lsp->hdr.lsp_id, lspid, true, true);
        vty_out(vty, "Flooding information for %s\n", lspid);
@@ -129,21 +130,10 @@ static void lsp_print_flooding(struct vty *vty, struct isis_lsp *lsp)
                lsp->flooding_interface : "(null)");
 
        time_t uptime = time(NULL) - lsp->flooding_time;
-       struct tm tm;
 
-       gmtime_r(&uptime, &tm);
+       frrtime_to_interval(uptime, buf, sizeof(buf));
 
-       if (uptime < ONE_DAY_SECOND)
-               vty_out(vty, "%02d:%02d:%02d", tm.tm_hour, tm.tm_min,
-                       tm.tm_sec);
-       else if (uptime < ONE_WEEK_SECOND)
-               vty_out(vty, "%dd%02dh%02dm", tm.tm_yday, tm.tm_hour,
-                       tm.tm_min);
-       else
-               vty_out(vty, "%02dw%dd%02dh", tm.tm_yday / 7,
-                       tm.tm_yday - ((tm.tm_yday / 7) * 7),
-                       tm.tm_hour);
-       vty_out(vty, " ago)\n");
+       vty_out(vty, "%s ago)\n", buf);
 
        if (lsp->flooding_circuit_scoped) {
                vty_out(vty, "    Received as circuit-scoped LSP, so not "