summaryrefslogtreecommitdiffstats
path: root/bgpd/bgp_route.c
diff options
context:
space:
mode:
authorDonatas Abraitis <donatas@opensourcerouting.org>2024-12-20 16:13:19 +0100
committerDonatas Abraitis <donatas@opensourcerouting.org>2024-12-20 16:58:49 +0100
commitb37f5f53b3ef37af4c70ca358d3e74ce73fdabd1 (patch)
tree9000e1a05b3ccfdbebe9cf1e03b9e13a76406b6d /bgpd/bgp_route.c
parentlib: Add a wrapper for time_to_string() to print time in JSON outputs (diff)
downloadfrr-b37f5f53b3ef37af4c70ca358d3e74ce73fdabd1.tar.xz
frr-b37f5f53b3ef37af4c70ca358d3e74ce73fdabd1.zip
bgpd: Replace ctime_r() to time_to_string[_json]() to handle JSON/non-JSON
For JSON output we don't need newline to be printed. Before: ``` "lastUpdate":{"epoch":1734490463,"string":"Wed Dec 18 04:54:23 2024\n" ``` After: ``` "lastUpdate":{"epoch":1734678560,"string":"Fri Dec 20 09:09:20 2024" ``` Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
Diffstat (limited to 'bgpd/bgp_route.c')
-rw-r--r--bgpd/bgp_route.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c
index e142d9661..3399c8a2d 100644
--- a/bgpd/bgp_route.c
+++ b/bgpd/bgp_route.c
@@ -11517,11 +11517,11 @@ void route_vty_out_detail(struct vty *vty, struct bgp *bgp, struct bgp_dest *bn,
json_last_update = json_object_new_object();
json_object_int_add(json_last_update, "epoch", tbuf);
json_object_string_add(json_last_update, "string",
- ctime_r(&tbuf, timebuf));
+ time_to_string_json(path->uptime, timebuf));
json_object_object_add(json_path, "lastUpdate",
json_last_update);
} else
- vty_out(vty, " Last update: %s", ctime_r(&tbuf, timebuf));
+ vty_out(vty, " Last update: %s", time_to_string(path->uptime, timebuf));
/* Line 10 display PMSI tunnel attribute, if present */
if (CHECK_FLAG(attr->flag, ATTR_FLAG_BIT(BGP_ATTR_PMSI_TUNNEL))) {