From sja@sja.home.tekla.fi  Fri Sep 20 09:57:55 1996
Received: from sja.home.tekla.fi (ppp8.tekla.fi [192.98.7.98])
          by freefall.freebsd.org (8.7.5/8.7.3) with ESMTP id JAA04890
          for <FreeBSD-gnats-submit@freebsd.org>; Fri, 20 Sep 1996 09:57:50 -0700 (PDT)
Received: (from sja@localhost) by sja.home.tekla.fi (8.7.5/8.7.3) id TAA00841; Fri, 20 Sep 1996 19:57:18 +0300 (EET DST)
Message-Id: <199609201657.TAA00841@sja.home.tekla.fi>
Date: Fri, 20 Sep 1996 19:57:18 +0300 (EET DST)
From: Sakari Jalovaara <sja@sja.home.tekla.fi>
Reply-To: sja@sja.home.tekla.fi
To: FreeBSD-gnats-submit@freebsd.org
Subject: ls(1) output of future mtime
X-Send-Pr-Version: 3.2

>Number:         1657
>Category:       bin
>Synopsis:       ls(1) output of future mtime
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:
>Keywords:
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Sep 20 10:00:01 PDT 1996
>Closed-Date:    Sat Jan 11 11:16:03 PST 1997
>Last-Modified:  Sat Jan 11 11:16:29 PST 1997
>Originator:     Sakari Jalovaara
>Release:        FreeBSD 2.2-960801-SNAP i386
>Organization:
>Environment:

	Any

>Description:

	If a file has modification time far in the future, the output
	of ls(1) does not show the modification year.  (Ditto for
	access and change times.)

>How-To-Repeat:

	Create a file with a modification time more than a year in the future
	(e.g. use "touch -t".)  Type "ls -lt".

	E.g.: (note that "Sep 13" seems to be sorted before "Sep 14", which
	is confusing)

	~/Xm (sja@estabur) 127> /bin/ls -lt DialogS*
	-rw-r--r--  1 sja  sja   5328 Sep 13 23:29 DialogS.c
	-rw-r--r--  1 sja  sja  62413 Sep 14 16:24 DialogS.o
	~/Xm (sja@estabur) 128> /bin/ls -ltT DialogS*
	-rw-r--r--  1 sja  sja   5328 Sep 13 23:29:31 2000 DialogS.c
	-rw-r--r--  1 sja  sja  62413 Sep 14 16:24:43 1996 DialogS.o

	(The cause of the above 4-year time warp is unknown.  Kernel
	bug, hardware clock glitch, ...?)

	ls should _not_ print the year for _all_ future times, since network
	file systems often cause time shifts of a few seconds.
	The year is useful for dates more than six months in the future.

>Fix:

	/usr/src/bin/ls/print.c, function printtime():

*** print.c.orig	Sat Sep 14 16:45:55 1996
--- print.c	Sat Sep 14 16:53:51 1996
***************
*** 231,236 ****
--- 231,240 ----
  {
  	int i;
  	char longstring[80];
+ 	static time_t now;
+ 
+ 	if (now == 0)
+ 		now = time(NULL);
  
  	strftime(longstring, sizeof(longstring), "%c", localtime(&ftime));
  	for (i = 4; i < 11; ++i)
***************
*** 240,246 ****
  	if (f_sectime)
  		for (i = 11; i < 24; i++)
  			(void)putchar(longstring[i]);
! 	else if (ftime + SIXMONTHS > time(NULL))
  		for (i = 11; i < 16; ++i)
  			(void)putchar(longstring[i]);
  	else {
--- 244,250 ----
  	if (f_sectime)
  		for (i = 11; i < 24; i++)
  			(void)putchar(longstring[i]);
! 	else if (ftime + SIXMONTHS > now && ftime < now + SIXMONTHS)
  		for (i = 11; i < 16; ++i)
  			(void)putchar(longstring[i]);
  	else {
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: mpp 
State-Changed-When: Sat Jan 11 11:16:03 PST 1997 
State-Changed-Why:  
Supplied patch applied. 
>Unformatted:
