Path: utzoo!utstat!jarvis.csri.toronto.edu!mailrus!shadooby!samsung!brutus.cs.uiuc.edu!apple!sun-barr!lll-winken!ncis.tis.llnl.gov!helios.ee.lbl.gov!surf.ee.lbl.gov!jef From: jef@surf.ee.lbl.gov (Jef Poskanzer) Newsgroups: news.software.b Subject: Re: Is anyone interested in putting local time in the "Date:" header? Message-ID: <4333@helios.ee.lbl.gov> Date: 30 Nov 89 06:11:07 GMT References: <14749@well.UUCP> Sender: usenet@helios.ee.lbl.gov Reply-To: Jef Poskanzer Organization: Paratheo-Anametamystikhood Of Eris Esoteric, Ada Lovelace Cabal Lines: 311 X-Local-Date: 29 Nov 89 22:11:07 PST Ok, appended is a shar containing two independent sets of context diffs. The first, inews.diffs, modifies B inews so that it adds the X-Local-Date header to locally-posted articles. The timezone stuff may not be portable - let me know if there are problems. The second, rn.diffs, modifies rn so that if the -Hx-local-date flag is set, the X-Local-Date header is used in preference to the Date header. If X-Local-Date does get used, it comes out as "Date". And the 'v' command is handled correctly. I was surprised at how small the necessary changes were. --- Jef Jef Poskanzer jef@well.sf.ca.us {ucbvax, apple, hplabs}!well!jef Baby on board. #! /bin/sh # This is a shell archive, meaning: # 1. Remove everything above the #! /bin/sh line. # 2. Save the resulting text in a file. # 3. Execute the file with /bin/sh (not csh) to create the files: # inews.diffs # rn.diffs # This archive created: Wed Nov 29 21:59:39 1989 # By: Jef Poskanzer export PATH; PATH=/bin:$PATH echo shar: extracting "'inews.diffs'" '(4845 characters)' if test -f 'inews.diffs' then echo shar: will not over-write existing file "'inews.diffs'" else sed 's/^X//' << \SHAR_EOF > 'inews.diffs' XContext diffs of Makefile.dst, header.c, funcs2.c, and rfc822.c: X X*** /tmp/,RCSt1a05961 Wed Nov 29 21:42:13 1989 X--- Makefile.dst Wed Nov 29 20:39:24 1989 X*************** X*** 38,43 **** X--- 38,44 ---- X #VMS LNRNEWS = cp # No links in Eunice X DEBUG = X SCCSID = -DSCCSID X+ LOCALDATE = -DLOCALDATE X X #NNTP SERVER= -DSERVER -I$(NNTPDIR)/common X X*************** X*** 69,79 **** X #BSD4_3 VFORK= X X #USG IBMFLAGS = X! #USG CFLAGS = ${DEBUG} -O $(IBMFLAGS) -DUSG -Dindex=strchr -Drindex=strrchr ${DEFS} ${SCCSID} ${VFORK} ${NETINCLUDE} X #USG LFLAGS = ${DEBUG} -s -i $(IBMFLAGS) X #USG LIBS = X #USG LINTFLAGS = -DUSG ${DEFS} ${NETINCLUDE} X! #V7 CFLAGS = ${DEBUG} -DDBM ${DEFS} ${SCCSID} ${VFORK} ${NETINCLUDE} X #V7 LFLAGS = ${DEBUG} X #V7 LIBS = -ldbm X #V7 LINTFLAGS = -chba -DDBM ${DEFS} ${NETINCLUDE} X--- 70,80 ---- X #BSD4_3 VFORK= X X #USG IBMFLAGS = X! #USG CFLAGS = ${DEBUG} -O $(IBMFLAGS) -DUSG -Dindex=strchr -Drindex=strrchr ${DEFS} ${SCCSID} ${LOCALDATE} ${VFORK} ${NETINCLUDE} X #USG LFLAGS = ${DEBUG} -s -i $(IBMFLAGS) X #USG LIBS = X #USG LINTFLAGS = -DUSG ${DEFS} ${NETINCLUDE} X! #V7 CFLAGS = ${DEBUG} -DDBM ${DEFS} ${SCCSID} ${LOCALDATE} ${VFORK} ${NETINCLUDE} X #V7 LFLAGS = ${DEBUG} X #V7 LIBS = -ldbm X #V7 LINTFLAGS = -chba -DDBM ${DEFS} ${NETINCLUDE} X*************** X*** 87,93 **** X X #VMS TERMLIB = -ltrmlib X #VMS LIBS = -ldbm X! #VMS CFLAGS = ${DEBUG} -O -DDBM ${DEFS} -DVMS ${SCCSID} ${VFORK} X #VMS MISC = uname.o X #VMS LINTFLAGS = -chba -DDBM -DVMS ${DEFS} X #VMS VFORK= X--- 88,94 ---- X X #VMS TERMLIB = -ltrmlib X #VMS LIBS = -ldbm X! #VMS CFLAGS = ${DEBUG} -O -DDBM ${DEFS} -DVMS ${SCCSID} ${LOCALDATE} ${VFORK} X #VMS MISC = uname.o X #VMS LINTFLAGS = -chba -DDBM -DVMS ${DEFS} X #VMS VFORK= X*** /tmp/,RCSt1a05961 Wed Nov 29 21:42:17 1989 X--- header.c Wed Nov 29 21:28:45 1989 X*************** X*** 656,665 **** X fprintf(fp, "Keywords: %s\n", hp->keywords); X fprintf(fp, "Message-ID: %s\n", hp->ident); X t = cgtdate(hp->subdate); X- fprintf(fp, "Date: %s\n", arpadate(&t)); X #ifdef LOCALDATE X fprintf(fp, "X-Local-Date: %s\n", localarpadate(&t)); X #endif /* LOCALDATE */ X #ifdef OLD X fprintf(fp, "Article-I.D.: %s\n", oident(hp->ident)); X fprintf(fp, "Posted: %s", ctime(&t)); X--- 656,665 ---- X fprintf(fp, "Keywords: %s\n", hp->keywords); X fprintf(fp, "Message-ID: %s\n", hp->ident); X t = cgtdate(hp->subdate); X #ifdef LOCALDATE X fprintf(fp, "X-Local-Date: %s\n", localarpadate(&t)); X #endif /* LOCALDATE */ X+ fprintf(fp, "Date: %s\n", arpadate(&t)); X #ifdef OLD X fprintf(fp, "Article-I.D.: %s\n", oident(hp->ident)); X fprintf(fp, "Posted: %s", ctime(&t)); X*** /tmp/,RCSt1a05961 Wed Nov 29 21:42:24 1989 X--- funcs2.c Wed Nov 29 20:39:28 1989 X*************** X*** 325,330 **** X--- 325,394 ---- X return b; X } X X+ #ifdef LOCALDATE X+ /* X+ * localarpadate is like arpadate except that it produces local time X+ * instead of GMT. X+ */ X+ char * X+ localarpadate(longtime) X+ time_t *longtime; X+ { X+ register char *p, *q, *ud; X+ register int i; X+ static char b[40]; X+ struct timeval tv; X+ struct timezone tz; X+ struct tm *tp; X+ char *tzn; X+ extern struct tm *localtime(); X+ extern char *asctime(), *timezone(); X+ X+ /* Get current time. This will be used resolve the timezone. */ X+ gettimeofday(&tv, &tz); X+ tp = localtime(longtime); X+ ud = asctime(tp); X+ X+ /* Crack the UNIX date line in a singularly unoriginal way. */ X+ q = b; X+ X+ #ifdef notdef X+ /* until every site installs the fix to getdate.y, the day X+ of the week can cause time warps */ X+ p = &ud[0]; /* Mon */ X+ *q++ = *p++; X+ *q++ = *p++; X+ *q++ = *p++; X+ *q++ = ','; *q++ = ' '; X+ #endif X+ X+ p = &ud[8]; /* 16 */ X+ if (*p == ' ') X+ p++; X+ else X+ *q++ = *p++; X+ *q++ = *p++; *q++ = ' '; X+ X+ p = &ud[4]; /* Sep */ X+ *q++ = *p++; *q++ = *p++; *q++ = *p++; *q++ = ' '; X+ X+ p = &ud[22]; /* 1979 */ X+ *q++ = *p++; *q++ = *p++; *q++ = ' '; X+ X+ p = &ud[11]; /* 01:03:52 */ X+ for (i = 8; i > 0; i--) X+ *q++ = *p++; X+ X+ tzn = timezone(tz.tz_minuteswest, tp->tm_isdst); X+ *q++ = ' '; X+ do { X+ *q++ = *tzn; X+ } while ( *tzn++ != '\0' ); X+ X+ return b; X+ } X+ #endif /* LOCALDATE */ X+ X char * X replyname(hptr) X struct hbuf *hptr; X*** /tmp/,RCSt1a05961 Wed Nov 29 21:42:28 1989 X--- rfc822.c Wed Nov 29 21:28:50 1989 X*************** X*** 262,271 **** X } X } else { X time(&t); X- fprintf(fp, "Date: %s\n", arpadate(&t)); X #ifdef LOCALDATE X fprintf(fp, "X-Local-Date: %s\n", localarpadate(&t)); X #endif /* LOCALDATE */ X } X if (*hp->expdate) X fprintf(fp, "Expires: %s\n", hp->expdate); X--- 262,271 ---- X } X } else { X time(&t); X #ifdef LOCALDATE X fprintf(fp, "X-Local-Date: %s\n", localarpadate(&t)); X #endif /* LOCALDATE */ X+ fprintf(fp, "Date: %s\n", arpadate(&t)); X } X if (*hp->expdate) X fprintf(fp, "Expires: %s\n", hp->expdate); SHAR_EOF if test 4845 -ne "`wc -c < 'inews.diffs'`" then echo shar: error transmitting "'inews.diffs'" '(should have been 4845 characters)' fi fi # end of overwriting check echo shar: extracting "'rn.diffs'" '(2196 characters)' if test -f 'rn.diffs' then echo shar: will not over-write existing file "'rn.diffs'" else sed 's/^X//' << \SHAR_EOF > 'rn.diffs' XContext diffs of head.h and art.c: X X*** /tmp/,RCSt1a06028 Wed Nov 29 21:53:06 1989 X--- head.h Wed Nov 29 21:34:11 1989 X*************** X*** 43,50 **** X #define SUMRY_LINE 24 /* summary */ X #define SUBJ_LINE 25 /* subject */ X #define XREF_LINE 26 /* xref */ X X! #define HEAD_LAST 27 /* one more than the last one above */ X X struct headtype { X char *ht_name; /* header line identifier */ X--- 46,54 ---- X #define SUMRY_LINE 24 /* summary */ X #define SUBJ_LINE 25 /* subject */ X #define XREF_LINE 26 /* xref */ X+ #define LOCALDATE_LINE 27 /* x-local-date */ X X! #define HEAD_LAST 28 /* one more than the last one above */ X X struct headtype { X char *ht_name; /* header line identifier */ X*************** X*** 95,101 **** X {"sender", 0, 0, 6, 0 }, X {"summary", 0, 0, 7, 0 }, X {"subject", 0, 0, 7, HT_MAGIC }, X! {"xref", 0, 0, 4, HT_HIDE } X }; X #endif X X--- 99,106 ---- X {"sender", 0, 0, 6, 0 }, X {"summary", 0, 0, 7, 0 }, X {"subject", 0, 0, 7, HT_MAGIC }, X! {"xref", 0, 0, 4, HT_HIDE }, X! {"x-local-date", 0, 0, 12, HT_HIDE } X }; X #endif X X*** /tmp/,RCSt1a06028 Wed Nov 29 21:53:09 1989 X--- art.c Wed Nov 29 21:52:52 1989 X*************** X*** 87,92 **** X--- 90,97 ---- X register char *s; X ART_POS artsize; /* size in bytes of article */ X bool hide_this_line = FALSE; /* hidden header line? */ X+ bool local_date_shown = FALSE; /* magic local date hack */ X+ bool date_shown = FALSE; /* magic local date hack */ X ART_LINE linenum; /* line # on page, 1 origin */ X #ifdef ULSMARTS X bool under_lining = FALSE; X*************** X*** 229,234 **** X--- 234,251 ---- X if (!(htype[EXPIR_LINE].ht_flags & HT_HIDE)) X hide_this_line = (strlen(art_buf) < 10); X } X+ else if (in_header == LOCALDATE_LINE) { X+ hide_this_line = FALSE; X+ local_date_shown = TRUE; X+ if (!date_shown && do_hiding) X+ strcpy(art_buf, &art_buf[8]); X+ } X+ } X+ if (in_header == DATE_LINE) { X+ if (local_date_shown) X+ hide_this_line = TRUE; X+ else X+ date_shown = TRUE; X } X if (in_header == SUBJ_LINE && X htype[SUBJ_LINE].ht_flags & HT_MAGIC) { SHAR_EOF if test 2196 -ne "`wc -c < 'rn.diffs'`" then echo shar: error transmitting "'rn.diffs'" '(should have been 2196 characters)' fi fi # end of overwriting check # End of shell archive exit 0