Subject: bin/2534: w should print user login time in hh:mm if it is today, but it doesn't.
To: None <gnats-bugs@NetBSD.ORG>
From: Tatoku Ogaito <tacha@tera.fukui-med.ac.jp>
List: netbsd-bugs
Date: 06/10/1996 11:18:07
>Number:         2534
>Category:       bin
>Synopsis:       w should print user login time in hh:mm if it is today, but it doesn't.
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    bin-bug-people (Utility Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Jun  9 22:50:02 1996
>Last-Modified:
>Originator:     Tatoku Ogaito
>Organization:
Tatoku Ogaito		| Email: tacha@tera.fukui-med.ac.jp
Department of Physics   | Fax:   +81 776-61-8141
Fukui Medical School  	| Tel:   +81 776-61-3111 ext 2446
>Release:        1.2_ALPHA as of 3 Jun 1995
>Environment:
System: NetBSD tera.fukui-med.ac.jp 1.2_ALPHA NetBSD 1.2_ALPHA (TERA) #1: Tue Jun 4 17:54:50 JST 1996 tacha@tera.fukui-med.ac.jp:/usr/current/src/sys/arch/i386/compile/TERA i386


>Description:
	According to the comments in pr_time.c, w should print 
user login-time in hh:mm{am,pm} format if the login-time is `today'.
But it works only TZ environment variable set to GMT.

>How-To-Repeat:
See `w' output around midnight in GMT.

[tera]~% date -u ; TZ=Japan date
Sun Jun 09 23:59:50 GMT 1996
Mon Jun 10 08:59:50 JST 1996
[tera]~% TZ=Japan w
08:59AM  up 5 days, 16:15, 2 users, load averages: 0.41, 0.69, 0.62
USER    TTY FROM              LOGIN@  IDLE WHAT
tacha    v0 -                 8:16AM     0 /usr/X11R6/bin/xinit 
tacha    p0 :0.0              8:17AM     0 w 
[tera]~% TZ=Japan date
Mon Jun 10 09:00:15 JST 1996
[tera]~% TZ=Japan w
09:00AM  up 5 days, 16:16, 2 users, load averages: 0.74, 0.68, 0.62
USER    TTY FROM              LOGIN@  IDLE WHAT
tacha    v0 -                Mon08AM     0 /usr/X11R6/bin/xinit 
tacha    p0 :0.0             Mon08AM     0 w 

>Fix:
*** /usr/src/usr.bin/w/pr_time.c	Fri Jun  7 20:48:55 1996
--- ./pr_time.c	Mon Jun 10 10:33:11 1996
***************
*** 65,71 ****
--- 65,73 ----
  	struct tm *tp;
  	time_t diff;
  	char fmt[20];
+ 	int  today;
  
+ 	today = localtime(now)->tm_yday;
  	tp = localtime(started);
  	diff = *now - *started;
  
***************
*** 74,80 ****
  		(void)strcpy(fmt, "%d%b%y");
  
  	/* If not today, use day-hour-am/pm. */
! 	else if (*now / SECSPERDAY != *started / SECSPERDAY) {
  		(void)strcpy(fmt, __CONCAT("%a%", "I%p"));
  	}
  
--- 76,82 ----
  		(void)strcpy(fmt, "%d%b%y");
  
  	/* If not today, use day-hour-am/pm. */
! 	else if (tp->tm_yday  != today ) {
  		(void)strcpy(fmt, __CONCAT("%a%", "I%p"));
  	}
  

>Audit-Trail:
>Unformatted: