summaryrefslogtreecommitdiff
path: root/usr.bin/rup
diff options
context:
space:
mode:
authorperry <perry@NetBSD.org>1997-01-16 22:18:16 +0000
committerperry <perry@NetBSD.org>1997-01-16 22:18:16 +0000
commitbf059fab25cee41e793ae584b7a255873fd4370a (patch)
treefb5a738ea8151dad4fae3aa06431a39e78981b2a /usr.bin/rup
parentf286cdd2825a221f2e4db7f18fcfa11ad5de1615 (diff)
make rup handle uptimes of more than 1 year per pr-3060
Diffstat (limited to 'usr.bin/rup')
-rw-r--r--usr.bin/rup/rup.c32
1 files changed, 18 insertions, 14 deletions
diff --git a/usr.bin/rup/rup.c b/usr.bin/rup/rup.c
index 42f5f8de99c..3c9b6570bf4 100644
--- a/usr.bin/rup/rup.c
+++ b/usr.bin/rup/rup.c
@@ -1,4 +1,4 @@
-/* $NetBSD: rup.c,v 1.12 1996/09/27 01:46:10 thorpej Exp $ */
+/* $NetBSD: rup.c,v 1.13 1997/01/16 22:18:16 perry Exp $ */
/*-
* Copyright (c) 1993, John Brezak
@@ -34,7 +34,7 @@
*/
#ifndef lint
-static char rcsid[] = "$NetBSD: rup.c,v 1.12 1996/09/27 01:46:10 thorpej Exp $";
+static char rcsid[] = "$NetBSD: rup.c,v 1.13 1997/01/16 22:18:16 perry Exp $";
#endif /* not lint */
#include <stdio.h>
@@ -188,7 +188,8 @@ print_rup_data(host, host_stat)
{
struct tm *tmp_time;
struct tm host_time;
- struct tm host_uptime;
+ unsigned ups=0,upm=0,uph=0,upd=0;
+
char days_buf[16];
char hours_buf[16];
@@ -199,24 +200,27 @@ print_rup_data(host, host_stat)
host_stat->curtime.tv_sec -= host_stat->boottime.tv_sec;
- tmp_time = gmtime((time_t *)&host_stat->curtime.tv_sec);
- host_uptime = *tmp_time;
+ ups=host_stat->curtime.tv_sec;
+ upd=ups/(3600*24);
+ ups-=upd*3600*24;
+ uph=ups/3600;
+ ups-=uph*3600;
+ upm=ups/60;
- if (host_uptime.tm_yday != 0)
- sprintf(days_buf, "%3d day%s, ", host_uptime.tm_yday,
- (host_uptime.tm_yday > 1) ? "s" : "");
+ if (upd != 0)
+ sprintf(days_buf, "%3u day%s, ", upd,
+ (upd > 1) ? "s" : "");
else
days_buf[0] = '\0';
- if (host_uptime.tm_hour != 0)
- sprintf(hours_buf, "%2d:%02d, ",
- host_uptime.tm_hour, host_uptime.tm_min);
+ if (uph != 0)
+ sprintf(hours_buf, "%2u:%02u, ",
+ uph, upm);
else
- if (host_uptime.tm_min != 0)
- sprintf(hours_buf, "%2d mins, ", host_uptime.tm_min);
+ if (upm != 0)
+ sprintf(hours_buf, "%2u mins, ", upm);
else
hours_buf[0] = '\0';
-
if (printtime)
printf(" %2d:%02d%cm",
(host_time.tm_hour % 12) ? (host_time.tm_hour % 12) : 12,