Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: $Revision: 1.6.2.16 $; site mirror.UUCP Path: utzoo!watmath!clyde!burl!ulysses!bellcore!decvax!cca!mirror!rs From: rs@mirror.UUCP Newsgroups: net.sources Subject: Re: Orphaned Response Message-ID: <12100010@mirror.UUCP> Date: Fri, 10-Jan-86 19:59:00 EST Article-I.D.: mirror.12100010 Posted: Fri Jan 10 19:59:00 1986 Date-Received: Thu, 23-Jan-86 21:08:35 EST References: <1536@ihlpg.UUCP> Lines: 192 Nf-ID: #R:ihlpg:-153600:mirror:12100010:177600:5290 Nf-From: mirror!rs Jan 10 19:59:00 1986 The formatted date capability of SystemV seemed kind of useful. The original program seemed kind of clunky, so I re-wrote it. I also fixed up some typo's and style errors in the manpage. Enjoy... /rich $alz # This is a shell archive. Remove anything before this line, # then unpack it by saving it in a file and typing "sh file". # # Wrapped by mirror!rs on Fri Jan 10 19:57:16 EST 1986 # Contents: mtime.1 mtime.c echo x - mtime.1 sed 's/^XX//' > "mtime.1" <<'@//E*O*F mtime.1//' XX.TH MTIME 1 "HFVR" XX.SH NAME XXmtime \- to display modification time of files XX.SH SYNOPSIS XXmtime { [+format] file}+ XX.SH DESCRIPTION XX\fIMtime\fR displays the last modification time of all files XXmentioned as argument. An argument starting with a ``+'' will be XXtreated to set the display format. The display format is then used for XXall files following the display format. The display format is similar XXto that of the first argument of \fIprintf\fR(3S). All output fields XXare of fixed size (zero padded if necessary). Each field descriptor XXis preceded by ``%'' and will be replaced in the output by its XXcorresponding value. A single ``%'' is encoded by ``%%''. All other characters XXare copied to the output without change. The string is always terminated XXwith a newline. XX.sp XXField descriptors: XX.nf XX \fBn\fR insert a new-line character XX \fBt\fR insert a tab character XX \fBm\fR month of year \- 01 to 12 XX \fBd\fR day of month \- 01 to 31 XX \fBy\fR last 2 digits of year \- 00 to 99 XX \fBD\fR date as in mm/dd/yy XX \fBH\fR hour \- 00 to 23 XX \fBM\fR minute \- 00 to 59 XX \fBS\fR second \- 00 to 59 XX \fBT\fR time as HH:MM:SS XX \fBj\fR day of year \- 001 to 366 XX \fBw\fR day of week \- Sunday = 0 XX \fBa\fR abbreviated weekday \- Sun to Sat XX \fBh\fR abbreviated month \- Jan to Dec XX.fi XX.sp XXThe default field descriptor is: XX.nf XX +%a %h %d %H:%M:%S 19%y XX.fi XX.SH EXAMPLES XX.nf XX mtime '+DATE:%m/%d/%y%nTIME: %H:%M:%S' file XXwould have generated as output: XX DATE: 08/01/76 XX TIME: 14:45:05 XX.fi XX.SH USEFUL FOR XX\fBmtime\fR is usefule for adding the last modification date to XXprintouts of databases etc. XX.SH SEE ALSO XX\fIstat\fP(3), \fIdate\fP(1), \fIprintf\fP(3S) XX.SH DIAGNOSTICS XXAn error message is displayed if a file cannot be \fIstat\fP(2)'ed. @//E*O*F mtime.1// chmod u=rw,g=rw,o=rw mtime.1 echo x - mtime.c sed 's/^XX//' > "mtime.c" <<'@//E*O*F mtime.c//' XX/* XX** Originally written by jchvr@ihlpg, "HFVR VERSION=Thu Mar 21 13:29:02 1985". XX** Rewritten by Rich $alz (rs@mirror), 10-Jan-86. XX** "Do with me what you will." XX*/ XX#include XX#include XX#include XX#include XXprformat(p, T) XX register char *p; XX register struct tm *T; XX{ XX static char DAY[] = "SunMonTueWedThuFriSat"; XX static char MON[] = "JanFebMarAprMayJunJulAugSepOctNovDec"; XX for (p++; *p; p++) XX if (*p != '%') XX printf("%c", *p); XX else XX switch (*++p) { XX default: XX printf("%c", *p); XX case '\0': XX break; XX case 'n': XX printf("\n"); XX break; XX case 't': XX printf("\t"); XX break; XX case 'm': XX printf("%.2d", T->tm_mon + 1); XX break; XX case 'd': XX printf("%.2d", T->tm_mday); XX break; XX case 'y': XX printf("%.2d", T->tm_year); XX break; XX case 'D': XX printf("%.2d/%.2d/%.2d", XX T->tm_mon + 1, T->tm_mday, T->tm_year); XX break; XX case 'H': XX printf("%.2d", T->tm_hour); XX break; XX case 'M': XX printf("%.2d", T->tm_min); XX break; XX case 'S': XX printf("%.2d", T->tm_sec); XX break; XX case 'T': XX printf("%.2d:%.2d:%.2d", T->tm_hour, T->tm_min, T->tm_sec); XX break; XX case 'j': XX printf("%.3d", T->tm_yday + 1); XX break; XX case 'w': XX printf("%.2d", T->tm_wday); XX break; XX case 'a': XX printf("%3.3s", &DAY[T->tm_wday * 3]); XX break; XX case 'h': XX printf("%3.3s", &MON[T->tm_mon * 3]); XX } XX printf("\n"); XX} XX#ifdef MAIN XX/* ARGSUSED */ XXmain(argc, argv) XX int argc; XX register char *argv[]; XX{ XX extern struct tm *localtime(); XX extern int errno; XX char *format = "+%a %h %d %H:%M:%S 19%y"; XX char *progname; XX struct stat filbuf; XX for (progname = *argv; *++argv; ) { XX if (**argv == '-') { XX fprintf(stderr, "Usage: %s { [+output-format] filename }*\n", XX progname); XX fprintf(stderr, "To display last modification date of file(s)\n"); XX exit(1); XX } XX if (**argv == '+') XX format = *argv; XX else if (stat(*argv, &filbuf) < 0) XX fprintf(stderr, "\007%s: error %d. Cannot work on: %s,\n", XX progname, errno, *argv); XX else { XX printf("%s: ", *argv); XX prformat(format, localtime(&filbuf.st_mtime)); XX } XX } XX exit(0); XX} XX#endif TEST @//E*O*F mtime.c// chmod u=rw,g=rw,o=rw mtime.c exit 0 -- Rich $alz {mit-eddie, ihnp4!inmet, wjh12, cca, datacube}!mirror!rs Mirror Systems 2067 Massachusetts Avenue Cambridge, MA, 02140 Telephone: 6,176,610,777