version 1.5, 1996/12/10 19:00:03 |
version 1.6, 1997/02/01 07:18:28 |
|
|
{ |
{ |
struct tm *tmp_time; |
struct tm *tmp_time; |
struct tm host_time; |
struct tm host_time; |
struct tm host_uptime; |
unsigned ups=0,upm=0,uph=0,upd=0; |
|
|
char days_buf[16]; |
char days_buf[16]; |
char hours_buf[16]; |
char hours_buf[16]; |
|
|
|
|
|
|
host_stat->curtime.tv_sec -= host_stat->boottime.tv_sec; |
host_stat->curtime.tv_sec -= host_stat->boottime.tv_sec; |
|
|
tmp_time = gmtime((time_t *)&host_stat->curtime.tv_sec); |
ups=host_stat->curtime.tv_sec; |
host_uptime = *tmp_time; |
upd=ups/(3600*24); |
|
ups-=upd*3600*24; |
|
uph=ups/3600; |
|
ups-=uph*3600; |
|
upm=ups/60; |
|
|
if (host_uptime.tm_yday != 0) |
if (upd != 0) |
sprintf(days_buf, "%3d day%s, ", host_uptime.tm_yday, |
sprintf(days_buf, "%3u day%s, ", upd, |
(host_uptime.tm_yday > 1) ? "s" : ""); |
(upd > 1) ? "s" : ""); |
else |
else |
days_buf[0] = '\0'; |
days_buf[0] = '\0'; |
|
|
if (host_uptime.tm_hour != 0) |
if (uph != 0) |
sprintf(hours_buf, "%2d:%02d, ", |
sprintf(hours_buf, "%2u:%02u, ", |
host_uptime.tm_hour, host_uptime.tm_min); |
uph, upm); |
else |
else |
if (host_uptime.tm_min != 0) |
if (upm != 0) |
sprintf(hours_buf, "%2d mins, ", host_uptime.tm_min); |
sprintf(hours_buf, "%2u mins, ", upm); |
else |
else |
hours_buf[0] = '\0'; |
hours_buf[0] = '\0'; |
|
|