aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeels Hofmeyr <neels@hofmeyr.de>2018-12-25 17:23:41 +0100
committerNeels Hofmeyr <neels@hofmeyr.de>2019-12-12 21:51:27 +0100
commitc4daec420cfd3a2b9ebcd7c241434a754122f566 (patch)
tree280d217a0c90ab397dd1f14bcd30b422cba50175
parentf1e54d08ca2afd44f155895113be6f6df84b9d52 (diff)
vty: show subscriber: change format of 'last LU seen'
So far, the time string format comes from ctime_r, and we manually add "UTC" to it. The ctime_r format is wildly chaotic IMHO, mixing weekday, day-of-month and hour and year in very unsorted ways. Adding "UTC" to it is non-standard. Instead use an ISO-8601 standardized time string via strftime(). Change-Id: I6731968f05050399f4dd43b241290186e0c59e1a
-rw-r--r--src/hlr_vty_subscr.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/src/hlr_vty_subscr.c b/src/hlr_vty_subscr.c
index 14a37f2..0512ff6 100644
--- a/src/hlr_vty_subscr.c
+++ b/src/hlr_vty_subscr.c
@@ -36,25 +36,25 @@ struct vty;
#define hexdump_buf(buf) osmo_hexdump_nospc((void*)buf, sizeof(buf))
-static char *
-get_datestr(const time_t *t, char *datebuf)
+static char *get_datestr(const time_t *t, char *buf, size_t bufsize)
{
- char *p, *s = ctime_r(t, datebuf);
+ struct tm *tm;
- /* Strip trailing newline. */
- p = strchr(s, '\n');
- if (p)
- *p = '\0';
- return s;
+ tm = gmtime(t);
+ if (!tm)
+ return "UNKNOWN";
+
+ strftime(buf, bufsize, "%FT%T+00:00", tm);
+ return buf;
}
static void dump_last_lu_seen(struct vty *vty, const char *domain_label, time_t last_lu_seen)
{
uint32_t age;
- char datebuf[26]; /* for ctime_r(3) */
+ char datebuf[32];
if (!last_lu_seen)
return;
- vty_out(vty, " last LU seen on %s: %s UTC", domain_label, get_datestr(&last_lu_seen, datebuf));
+ vty_out(vty, " last LU seen on %s: %s", domain_label, get_datestr(&last_lu_seen, datebuf, sizeof(datebuf)));
if (!timestamp_age(&last_lu_seen, &age))
vty_out(vty, " (invalid timestamp)%s", VTY_NEWLINE);
else