summaryrefslogtreecommitdiffstats
path: root/usr.bin/w
diff options
context:
space:
mode:
authordavidn <davidn@FreeBSD.org>1999-11-10 04:28:16 +0000
committerdavidn <davidn@FreeBSD.org>1999-11-10 04:28:16 +0000
commiteb0978086d5ef277c9bc2b7c5addf2020f8d47d8 (patch)
tree5056884b13974b718fe8fecfb490b9010da6182e /usr.bin/w
parentd8b9f4c9fa7e2ab435fbd84a0584f941947e01fc (diff)
downloadFreeBSD-src-eb0978086d5ef277c9bc2b7c5addf2020f8d47d8.zip
FreeBSD-src-eb0978086d5ef277c9bc2b7c5addf2020f8d47d8.tar.gz
Fix cosmetic bug in time display. Current day logins are now displayed
as plain time as originally intended, instead of displaying DayHH times when the login time happens to be prior the GMT - TZ difference. (Only noticable on systems operating east of GMT/UTC). Local times are now used to determine the day.
Diffstat (limited to 'usr.bin/w')
-rw-r--r--usr.bin/w/pr_time.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/usr.bin/w/pr_time.c b/usr.bin/w/pr_time.c
index 2a7eb1d..4b9614c 100644
--- a/usr.bin/w/pr_time.c
+++ b/usr.bin/w/pr_time.c
@@ -59,11 +59,12 @@ pr_attime(started, now)
time_t *started, *now;
{
static char buf[256];
- struct tm *tp;
+ struct tm tp, tm;
time_t diff;
char fmt[20];
- tp = localtime(started);
+ tp = *localtime(started);
+ tm = *localtime(now);
diff = *now - *started;
/* If more than a week, use day-month-year. */
@@ -71,7 +72,11 @@ pr_attime(started, now)
(void)strcpy(fmt, "%d%b%y");
/* If not today, use day-hour-am/pm. */
- else if (*now / 86400 != *started / 86400) {
+ else if (tm.tm_mday != tp.tm_mday ||
+ tm.tm_mon != tp.tm_mon ||
+ tm.tm_year != tp.tm_year) {
+ /* The line below does not take DST into consideration */
+ /* else if (*now / 86400 != *started / 86400) { */
(void)strcpy(fmt, __CONCAT("%a%", "I%p"));
}
@@ -80,7 +85,7 @@ pr_attime(started, now)
(void)strcpy(fmt, __CONCAT("%l:%", "M%p"));
}
- (void)strftime(buf, sizeof(buf) - 1, fmt, tp);
+ (void)strftime(buf, sizeof(buf) - 1, fmt, &tp);
buf[sizeof(buf) - 1] = '\0';
(void)printf("%s", buf);
}
OpenPOWER on IntegriCloud