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

Hi,

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:
|=20
| date "+%b %e %H:%M"
|=20
| if the file has been modified in the last six months, or:
|=20
| date "+%b %e %Y"
|=20
| (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
(lapdog)=20

I believe it should do:

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


This is the patch:

Index: print.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
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++)
                        (void)putchar(longstring[i]);
-       else if (ftime + SIXMONTHS > now && ftime - SIXMONTHS < now)
+       else if (ftime + SIXMONTHS > now && ftime <=3D now)
                for (i =3D 11; i < 16; ++i)
                        (void)putchar(longstring[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.

-Jan

--=20
Tradition is the illusion of permanence. -- Woody Allen

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

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (NetBSD)

iD8DBQFBE9/FfFtkr68iakwRAtMBAKDAIGmI31GWTlq3VzeqXFOmRs/kagCfdGis
k2kHPf4oTLSQDR+B4W2fXVc=
=YtlV
-----END PGP SIGNATURE-----

--uxuisgdDHaNETlh8--