diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 1996-06-17 01:36:02 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 1996-06-17 01:36:02 +0000 |
commit | dec652ac608156087fad7746511297ecfab44696 (patch) | |
tree | 3fe9761bd18341957a4eade755f06303a4a73f71 | |
parent | 7f2e0c44ba5e0f1c6e4755779b88367f1aabb0cb (diff) |
print days correct; also deal with today correctly, netbsd pr#2534, tacha@tera.fukui-med.ac.jp
-rw-r--r-- | usr.bin/w/pr_time.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/usr.bin/w/pr_time.c b/usr.bin/w/pr_time.c index 86b5a40a649..c126969a265 100644 --- a/usr.bin/w/pr_time.c +++ b/usr.bin/w/pr_time.c @@ -59,7 +59,9 @@ pr_attime(started, now) struct tm *tp; time_t diff; char fmt[20]; + int today; + today = localtime(now)->tm_yday; tp = localtime(started); diff = *now - *started; @@ -68,7 +70,7 @@ pr_attime(started, now) (void)strcpy(fmt, "%d%b%y"); /* If not today, use day-hour-am/pm. */ - else if (*now / SECSPERDAY != *started / SECSPERDAY) { + else if (tp->tm_yday != today ) { (void)strcpy(fmt, __CONCAT("%a%", "I%p")); } @@ -91,8 +93,7 @@ pr_idle(idle) { /* If idle more than 36 hours, print as a number of days. */ if (idle >= 36 * SECSPERHOUR) - (void)printf(" %dday%c ", idle / SECSPERDAY, - idle >= 24 * SECSPERHOUR ? 's' : ' '); + printf(days == 1 ? " %dday " : " %ddays ", days); /* If idle more than an hour, print as HH:MM. */ else if (idle >= SECSPERHOUR) |