Change in osmo-hlr[master]: vty: show subscriber: show lu d, h, m, s ago, not just seconds

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

laforge gerrit-no-reply at lists.osmocom.org
Fri May 1 14:37:40 UTC 2020


laforge has submitted this change. ( https://gerrit.osmocom.org/c/osmo-hlr/+/16262 )

Change subject: vty: show subscriber: show lu d,h,m,s ago, not just seconds
......................................................................

vty: show subscriber: show lu d,h,m,s ago, not just seconds

Change-Id: I0fe34e0f065160ef959b2b7b4dd040f3f2985f43
---
M src/hlr_vty_subscr.c
1 file changed, 14 insertions(+), 2 deletions(-)

Approvals:
  Jenkins Builder: Verified
  laforge: Looks good to me, approved



diff --git a/src/hlr_vty_subscr.c b/src/hlr_vty_subscr.c
index 8079d10..a9262ba 100644
--- a/src/hlr_vty_subscr.c
+++ b/src/hlr_vty_subscr.c
@@ -53,8 +53,20 @@
 	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
-		vty_out(vty, " (%us ago)%s", age, VTY_NEWLINE);
+	else {
+		vty_out(vty, " (");
+#define UNIT_AGO(UNITNAME, UNITVAL) \
+		if (age >= (UNITVAL)) { \
+			vty_out(vty, "%u%s", age / (UNITVAL), UNITNAME); \
+			age = age % (UNITVAL); \
+		}
+		UNIT_AGO("d", 60*60*24);
+		UNIT_AGO("h", 60*60);
+		UNIT_AGO("m", 60);
+		UNIT_AGO("s", 1);
+		vty_out(vty, " ago)%s", VTY_NEWLINE);
+#undef UNIT_AGO
+	}
 }
 
 static void subscr_dump_full_vty(struct vty *vty, struct hlr_subscriber *subscr)

-- 
To view, visit https://gerrit.osmocom.org/c/osmo-hlr/+/16262
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-hlr
Gerrit-Branch: master
Gerrit-Change-Id: I0fe34e0f065160ef959b2b7b4dd040f3f2985f43
Gerrit-Change-Number: 16262
Gerrit-PatchSet: 25
Gerrit-Owner: neels <nhofmeyr at sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge at osmocom.org>
Gerrit-Reviewer: neels <nhofmeyr at sysmocom.de>
Gerrit-Reviewer: osmith <osmith at sysmocom.de>
Gerrit-CC: pespin <pespin at sysmocom.de>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20200501/0f5f64a9/attachment.htm>


More information about the gerrit-log mailing list