bed_gdg@SHSU.BITNET ("George D. Greenwade") (02/21/91)
As I have been going through back issues of TeXhax stripping headers and looking for interesting style/macro file contributions to place on FILESERV, I came across a contribution in Volume 89, Issue 67 (Friday, July 14, 1989) from Dimitri Vulis <DLV@CUNYVMS1.BITNET> for a weekday macro. Everything above the commented in line is the original macro (which works as a LaTeX style file I would like to ultimately name WEEKDAY.STY). Below the commented line I am again showing my ignorance in TeX. Dimitri's contribution yields Sunday, Monday, ... , Saturday from a date (i.e., placing in the command "\weekday{1776}{7}{4}," yields "Sunday,"). What I would like to do is make this read "Sunday, July 4, 1776,". That is done in my modification, "\weekdaydisplay{1776}{7}{4}" (or at least appears to be!). The problem is that Dimitri's command "\weekday{\year}{\month}{\day}," yields "Wednesday" (the correct day as I write this), but my variant of this "\weekdaydisplay{\year}{\month}{\day}," yields only "Wednesday, Feburary, ," and the list file says: ! Missing number, treated as zero. <to be read again> , \weekdaydisplay ...\or November\or December\fi \space #3, \space #1 l.8 ...nclude \weekdaydisplay{\year}{\month}{\day} , ? ! Missing number, treated as zero. <to be read again> , l.8 ...clude \weekdaydisplay{\year}{\month}{\day}, ? I'm probably missing something obvious, but what? %% WEEKDAY.STY -- original source: Dimitri Vulis <DLV@CUNYVMS1.BITNET> with %% modifications by George D. Greenwade <BED_GDG@SHSU.BITNET>, who begs the %% help of INFO-TeX and comp.text.tex readers for assistance. %% 20-FEB-1991 15:24:06 \catcode`\@=11\relax \newcount\wwwy \newcount\wwwm \newcount\wwwd \newcount\wwwc \newcount\wwwt \newcount\wwws \def\weekday@{ \wwwc=\wwwy \divide\wwwc100\relax \wwwt=-\wwwc \multiply\wwwt100\relax \advance\wwwy\wwwt \wwws=\wwwy \multiply\wwws1461\relax \divide\wwws4\relax \wwwt=\wwwm \multiply\wwwt764\relax \divide\wwwt25\relax \advance\wwws\wwwt \advance\wwws\wwwd \ifnum\wwwm>\tw@\advance\wwws\thr@@\else \weekday@@ \fi \wwwt=-\wwws \divide\wwwt7\relax \multiply\wwwt7\relax \advance\wwws\wwwt } % By the year 2000 we ought to examine \wwwc as well \def\weekday@@{ \wwwt=\wwwy \divide\wwwt4\relax \multiply\wwwt4\relax \advance\wwwt-\wwwy \ifnum\wwwt=\z@\advance\wwws4 \else \advance\wwws5 \fi } \def\weekday#1#2#3{ % year, month 1--12, day 1--31 \wwwy=#1\relax\wwwm=#2\relax\wwwd=#3\relax \weekday@ \ifcase\wwws Sunday\or Monday\or Tuesday\or Wednesday\or Thursday\or Friday\or Saturday\fi} %%%% End of Dimitri's original code, which works fine %%%% %%%%%%%%%%%%%% Begining of my problem child %%%%%%%%%%%%%% \def\weekdaydisplay#1#2#3{ % year, month 1--12, day 1--31 \wwwy=#1\relax\wwwm=#2\relax\wwwd=#3\relax \weekday@ \ifcase\wwws Sunday,\or Monday,\or Tuesday,\or Wednesday,\or Thursday,\or Friday,\or Saturday,\fi \space \ifcase #2\or January\or February\or March\or April\or May\or June\or July\or August\or September\or October\or November\or December\fi \space#3, \space#1 \fi} %%%%%%%%%%%%%%%% And finally, a test file for use %%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%% stolen and modified from %%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%% Dimitri's original TeXhax post %%%%%%%%%%%%%%%%% \documentstyle[weekday]{article} \begin{document} For example, notable weekdays include \weekday{\year}{\month}{\day}, \weekday{1776}{7}{4}, \weekday{1918}{11}{11}, and \weekday{1964}{12}{29}. For example, notable weekdays include \weekdaydisplay{\year}{\month}{\day}, \weekdaydisplay{1776}{7}{4}, \weekdaydisplay{1918}{11}{11}, and \weekdaydisplay{1964}{12}{29}. \end{document} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %George D. Greenwade, Ph.D. Bitnet: BED_GDG@SHSU% %Department of Economics and Business Analysis THEnet: SHSU::BED_GDG% %P. O. Box 2118 Voice: (409) 294-1266% %Sam Houston State University FAX: (409) 294-3612% %Huntsville, TX 77341 Internet: bed_gdg%shsu.decnet@relay.the.net% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%