[comp.text.tex] WEEKDAY style fixed -- thanks!

bed_gdg@SHSU.BITNET ("George D. Greenwade") (02/21/91)

Quick note (while the system is open and prior to class):
 
I received 14 fixes to my post of yesterday re: the weekday problem.  All
were tried; all worked!  (I knew INFO-TeX would come in handy someday --
let's see, that was 14 responses in 14 hours, so ...; did get some other
interesting variations and even more info than I thought might be relevant,
but it was, of course)
 
Below is a post of the "fixed" file.  It is available on FILESERV for future
reference.  Again, thanks to all!  (Bernhard is credited as he was one of
the first to respond and put all of this in a final file format)
 
George
 
% Save file as: WEEKDAY.STY            Source: FILESERV@SHSU.BITNET
%% WEEKDAY.STY -- original source: Dimitri Vulis <DLV@CUNYVMS1.BITNET> with
%%  modifications by George D. Greenwade <BED_GDG@SHSU.BITNET>, and gracious
%%  assistance from Bernhard Schroeder <UPK002@DBNRHRZ1.BITNET> and others
%%  via INFO-TeX/comp.text.tex.  21-FEB-1991 07:51:27
%%
%% Usage: \weekday{yyyy}{mm}{dd} (where "yyyy" is a year, "mm" is the numeric
%%        equilavent of the month, and "dd" is the specific calendar date
%%        which may be one or two numbers) yields the weekday associated with
%%        the date provided (i.e., Sunday, Monday, ...).  May pass \year,
%%        \month, and \day to generate today's weekday.
%%
%%    --  \weekdaydate{yyyy}{mm}{dd} yields result of \weekday, as well as the
%%        calendar date (i.e., \weekdaydate{1991}{02}{21} yields Thursday,
%%        February 21, 1991).  (NOTE: syntax is changed from \weekdaydisplay
%%        to \weekdaydate to make it a little more rememberable)
%%
%% May be used as a TeX macro or as a LaTeX style, from what I can tell.
%% Please report any enhancements or bugs you come across so they can be
%%    posted in FILESERV's STYle archives.  George <BED_GDG@SHSU.BITNET>
%%
\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}
 
\def\weekdaydate#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\number#3, \space\number#1}  % Here I (Bernhard) inserted \number