Blame SOURCES/procps-ng-3.3.15-uptime-pretty-mod.patch

831195
From 7eade2544e1c45bc516744aeaccc45df1d8f42df Mon Sep 17 00:00:00 2001
831195
From: Kyle Walker <kwalker@redhat.com>
831195
Date: Tue, 11 Feb 2020 14:30:39 -0500
831195
Subject: [PATCH] whattime: Refactor the pretty-print evaluation
831195
831195
This avoids rounding errors such as in the case of 364 days of uptime which
831195
results in only output that prints at the hour and below.
831195
---
831195
 proc/whattime.c | 15 ++++++++++++---
831195
 1 file changed, 12 insertions(+), 3 deletions(-)
831195
831195
diff --git a/proc/whattime.c b/proc/whattime.c
831195
index c223cad..3e1b65c 100644
831195
--- a/proc/whattime.c
831195
+++ b/proc/whattime.c
831195
@@ -69,9 +69,18 @@ char *sprint_uptime(int human_readable) {
831195
 
831195
   if (human_readable) {
831195
     updecades = (int) uptime_secs / (60*60*24*365*10);
831195
-    upyears = ((int) uptime_secs / (60*60*24*365)) % 10;
831195
-    upweeks = ((int) uptime_secs / (60*60*24*7)) % 52;
831195
-    updays = ((int) uptime_secs / (60*60*24)) % 7;
831195
+    if (updecades)
831195
+        uptime_secs -= updecades * (60*60*24*365*10);
831195
+
831195
+    upyears = (int) uptime_secs / (60*60*24*365);
831195
+    if (upyears)
831195
+        uptime_secs -= upyears * (60*60*24*365);
831195
+
831195
+    upweeks = (int) uptime_secs / (60*60*24*7);
831195
+    if (upweeks)
831195
+        uptime_secs -= upweeks * (60*60*24*7);
831195
+
831195
+    updays = (int) uptime_secs / (60*60*24);
831195
   }
831195
   else
831195
     updays = (int) uptime_secs / (60*60*24);
831195
-- 
831195
2.24.1
831195