summaryrefslogtreecommitdiffstats
path: root/isisd
diff options
context:
space:
mode:
authorDonald Sharp <sharpd@cumulusnetworks.com>2020-03-17 11:47:15 +0100
committerGitHub <noreply@github.com>2020-03-17 11:47:15 +0100
commit218326d04a05c6eb7575edc7169782457095d936 (patch)
treebe5e8040f6f8b9f36a5b7979331702b8a7dcc013 /isisd
parentMerge pull request #5940 from patrasar/214257 (diff)
parentlib, *: add a common time interval formatting api (diff)
downloadfrr-218326d04a05c6eb7575edc7169782457095d936.tar.xz
frr-218326d04a05c6eb7575edc7169782457095d936.zip
Merge pull request #5927 from mjstapp/interval_string_api
lib, *: add a common time interval formatting api
Diffstat (limited to 'isisd')
-rw-r--r--isisd/isis_misc.c18
-rw-r--r--isisd/isis_vty_fabricd.c16
2 files changed, 8 insertions, 26 deletions
diff --git a/isisd/isis_misc.c b/isisd/isis_misc.c
index 5fa33f550..96b76da92 100644
--- a/isisd/isis_misc.c
+++ b/isisd/isis_misc.c
@@ -562,20 +562,12 @@ void vty_multiline(struct vty *vty, const char *prefix, const char *format, ...)
void vty_out_timestr(struct vty *vty, time_t uptime)
{
- struct tm tm;
time_t difftime = time(NULL);
+ char buf[MONOTIME_STRLEN];
+
difftime -= uptime;
- gmtime_r(&difftime, &tm);
-
- if (difftime < ONE_DAY_SECOND)
- vty_out(vty, "%02d:%02d:%02d", tm.tm_hour, tm.tm_min,
- tm.tm_sec);
- else if (difftime < 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");
+ frrtime_to_interval(difftime, buf, sizeof(buf));
+
+ vty_out(vty, "%s ago", buf);
}
diff --git a/isisd/isis_vty_fabricd.c b/isisd/isis_vty_fabricd.c
index 88f7337a9..09b8d2825 100644
--- a/isisd/isis_vty_fabricd.c
+++ b/isisd/isis_vty_fabricd.c
@@ -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 "