Subject: ls(1) and dates in the future
To: None <>
From: Jan Schaumann <>
List: tech-userlevel
Date: 08/06/2004 15:45:09
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable


For the way ls(1) should display the dates, SUSv3 says:

| The <date and time> field shall contain the appropriate date and
| timestamp of when the file was last modified. In the POSIX locale, the
| field shall be the equivalent of the output of the following date
| command:
| date "+%b %e %H:%M"
| if the file has been modified in the last six months, or:
| date "+%b %e %Y"
| (where two <space>s are used between %e and %Y ) if the file has not
| been modified in the last six months or if the modification date is in
| the future

Our ls(1), however, displays dates for files that are less than six
months in the future as normal:

(lapdog) date
Fri Aug  6 15:33:40 EDT 2004
(lapdog) touch -t 200408100000 foo
(lapdog) ls -l foo
-rw-------  1 jschauma  wheel  308 Aug 10 00:00 foo

I believe it should do:

-rw-------  1 jschauma  wheel  308 Aug 10  2004 foo

This is the patch:

Index: print.c
RCS file: /cvsroot/src/bin/ls/print.c,v
retrieving revision 1.38
diff -b -u -r1.38 print.c
- --- print.c     26 Dec 2003 06:19:19 -0000      1.38
+++ print.c     31 Jul 2004 19:44:57 -0000
@@ -385,7 +385,7 @@
        if (f_sectime)
                for (i =3D 11; i < 24; i++)
-       else if (ftime + SIXMONTHS > now && ftime - SIXMONTHS < now)
+       else if (ftime + SIXMONTHS > now && ftime <=3D now)
                for (i =3D 11; i < 16; ++i)
        else {

Is that correct?  FWIW, GNU ls(1) and IRIX' ls(1) do show the year for
anything in the future, while FreeBSD's behaves as ours and OpenBSD's
doesn't seem to care about future dates at all.


Tradition is the illusion of permanence. -- Woody Allen

Content-Type: application/pgp-signature
Content-Disposition: inline

Version: GnuPG v1.2.3 (NetBSD)