Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!elroy.jpl.nasa.gov!ncar!ico!ism780c!jeff From: jeff@ism780c.isc.com (Jeff Copeland) Newsgroups: comp.text Subject: Re: Printing file modification date in *roff. Message-ID: <43134@ism780c.isc.com> Date: 31 May 90 18:53:03 GMT References: <1990May30.163357.6070@gtisqr.uucp> Reply-To: jeff@ism780c.UUCP (Jeff Copeland) Distribution: na Organization: Interactive Systems Corp., Santa Monica CA Lines: 58 In article <1990May30.163357.6070@gtisqr.uucp> roger@gtisqr.UUCP (Roger Droz) writes: >I am always forgetting to change the revision date when I modify a >document, so I wonder if there is a way to automatically date a file >with its modification date. There is actually a fairly general way to do this with the .sy troff directive, and the ls command, but because you use RCS, the problem is a lot simpler: In simplest form, add a macro like: .de rD This document last revised on \\$2. .. and then include the text: .rD $Date$ in your document where you want the revision date to appear. Alternately, if you want to rearrange the yy/mm/dd format RCS forces you to use, try something like: .de DT\" get the date out of the RCS Header line .if !"\\$7"Locked" \{\ .tr / .de NR .br .nr yr \\\\$1 .nr mo \\\\$2 .nr dy \\\\$3 \\.. .di X \\!.NR \\$4 .di .X .rm X NR .tr // .\} .. This macro sets the troff number registers for the date. It expects a $Header$ line rather than a $Date$ line, so that if the file is locked, it takes no action and today's date is used instead. Defining a macro on the fly and then diverting the macro breaks out the components of the date by translating the / to a blank. The macro is used like this: .\" setup the date .DT $Header: rr,v 1.4 90/03/23 16:43:47 jeff Exp $ .ie \n(mo-11 \n(dy December 19\n(yr .el .ie \n(mo-10 \n(dy November 19\n(yr .el .ie \n(mo-9 \n(dy October 19\n(yr .el .ie \n(mo-8 \n(dy September 19\n(yr .el .ie \n(mo-7 \n(dy August 19\n(yr .el .ie \n(mo-6 \n(dy July 19\n(yr .el .ie \n(mo-5 \n(dy June 19\n(yr .el .ie \n(mo-4 \n(dy May 19\n(yr .el .ie \n(mo-3 \n(dy April 19\n(yr .el .ie \n(mo-2 \n(dy March 19\n(yr .el .ie \n(mo-1 \n(dy February 19\n(yr .el \n(dy January 19\n(yr Enjoy.