%\iffalse
%
% file: evntlist.dtx
% Copyright (C) 1996-1997 by Frank Bennett.  All rights reserved.
%
% IMPORTANT NOTICE:
% 
% You are not allowed to change this file.  You may however copy
% this file to a file with a different name and then change the
% copy if (a) you do not charge for the modified code, (b) you
% acknowledge the author of this file in the new file, if it
% is distributed to others, and (c) you attach these same
% conditions to the new file.
% 
% You are not allowed to distribute this file alone.  You are not
% allowed to take money for the distribution or use of this file
% (or a changed version) except for a nominal charge for copying
% etc.
% 
% You are allowed to distribute this file under the condition that
% it is distributed with all of its contents, intact.
% 
% For error reports, or offers to help make this a more powerful,
% friendlier, and altogether more thrilling package, please contact me on
% fb@soas.ac.uk.  Better yet, make a contribution to
% my pension.  Account details available on request.
%
%\fi
%
% \def\fileversion{2.2}
% \def\filedate{1997/11/07 10:44:05}
%
% \iffalse
%
%<*driver>
\documentclass{ltxdoc}
%\CodelineIndex
%\EnableCrossrefs
\begin{document}
\OnlyDescription    % Comment out for implementation details
\DocInput{evntlist.dtx}
\end{document}
%</driver>
%\fi
%
%\iffalse
% evntlist.dtx,v
% Revision 3.1.1.1  1998/01/17 18:14:57  root
% Release code, checksum verified
%
% Revision 3.1  1998/01/17 17:12:58  root
% Release code
%
% Revision 1.3  1998/01/16 17:46:34  root
% *** empty log message ***
%
% Revision 1.2  1998/01/15 23:39:20  root
% *** empty log message ***
%
% Revision 1.1  1997/11/26 07:20:12  bennett
% Initial revision
%
%\fi
%
% \title{User's Guide to the Event List 
%    package\thanks{This file is version number
%    \fileversion{}.  It was last revised on
%    \filedate{}.}}
%
% \author{Frank G. Bennett, Jr.}
%
% \maketitle
%
% \setcounter{StandardModuleDepth}{1}
% \DeleteShortVerb{\|}
% \MakeShortVerb{\"}
%
% \begin{abstract}
% \noindent This package makes a cronological list
%  of events.
% \end{abstract}
%
% \CheckSum{133}
%
% Please see the file \texttt{calguide.tex} for details on the
% use of this package.
%
% \StopEventually{\PrintIndex}
%
% \section{The Class File}
%
% \subsection{Preliminaries}
% Use \LaTeXe, and tell the user who we are.
%    \begin{macrocode}
%<*style>
\NeedsTeXFormat{LaTeX2e}[1995/06/01]
\ProvidesPackage{evntlist}
          [1997/11/07 10:44:05 2.2 Event List (Frank Bennett)]
%    \end{macrocode}
% Define some more variables and switches for use in the body
% of the style.
%
% \subsection{Options}
%
% In common with all other packages in the Calendar
% bundle, we
% include some code for declaring languages.
%
%    \begin{macrocode}
\input calopts.cfg
\InputIfFileExists{dates.cfg}{}{}
\ProcessOptions
%    \end{macrocode}
%
% \subsection{Option Postprocessing}
%
% Now that the options lists are available to us,
% we can start loading packages.  The following packages
% are always loaded.
%    \begin{macrocode}
\RequirePackage{calendar}
%    \end{macrocode}
% The "color" package is only loaded if the user asked
% for it as an option to \sc{documentclass}, or in the
% "weekly.cfg" file.
%    \begin{macrocode}
 \newif\if@el@noheadyet
 \@el@noheadyettrue
 \def\el@output#1{\protected@write\@el@outputfile{}{#1}}
 \def\el@maybeheader{\if@el@noheadyet%
   \begin{itemize}\item\theday\space\themonth\space\theyear\@el@noheadyetfalse\fi}
 \def\el@maybeitem{\if@el@noheadyet\else\item\theday\space\themonth\space\theyear%
 \fi}
%    \end{macrocode}
%
% \subsection{Calendar Setup}
%
% \subsection{Calendar Definition}
%
% The calendar definition itself consists of a single command
% and its associated arguments.
%    \begin{macrocode}
\newcalendar%
%    \end{macrocode}
% We give the environment a name.
%    \begin{macrocode}
{eventlist}
%    \end{macrocode}
% We're producing DVI, so we use the standard
% macro for dropping text into the hopper.
%    \begin{macrocode}
{\cal@insert}
%    \end{macrocode}
% Starting day for the calendar is not fixed here,
% because we don't pad with blank entries.  Season to taste.
% Use integers "0" through "6".  A value over 7 means no padding.
%    \begin{macrocode}
{8}
%    \end{macrocode}
% The length of a group is one day.
%    \begin{macrocode}
{1}
%    \end{macrocode}
% The length of a subgroup is one day.
%    \begin{macrocode}
{1}
%    \end{macrocode}
% Our delimiter is an \cs{item}.
%    \begin{macrocode}
{\relax}
%    \end{macrocode}
% Increment the date counter with every item.
%    \begin{macrocode}
{I}
%    \end{macrocode}
% Define the header.
%    \begin{macrocode}
{\relax}
%    \end{macrocode}
% We define the end of the calendar.  This spits out
% all of the boxes one last time, and closes the page
% formatting environment.
%    \begin{macrocode}
{\end{itemize}}
%    \end{macrocode}
% We define a way to open a new group.  In this case,
% we just relax.
%    \begin{macrocode}
{\relax}
%    \end{macrocode}
% We define the way to end a subgroup.  This spits out
% all of the boxes built for a page of text.
%    \begin{macrocode}
{\relax}
%    \end{macrocode}
% We set up to require a month and day in the environment typed
% into the user's document.
%    \begin{macrocode}
{\dates@requiremonthtrue\dates@requiredaytrue}
%    \end{macrocode}
% The next section runs after the calendar dates have been
% scanned from the environment, but before the table is
% opened.
% \textit{Start date.}
%    \begin{macrocode}
{\global\dates@date\cal@range@start%
 \caldate%
%    \end{macrocode}
% \textit{We tell the user where we're starting.}
%    \begin{macrocode}
  \message{^^JStart: \theshortweekday\space%
    \theday\space\theshortmonth\space\theyear}%
%    \end{macrocode}
% \textit{End date.}
%    \begin{macrocode}
  \global\dates@date\cal@range@end%
  \caldate%
%    \end{macrocode}
% \textit{We let the user know where we plan to stop.}
%    \begin{macrocode}
  \message{^^JEnd: \theshortweekday\space%
    \theday\space\theshortmonth\space\theyear}%
%    \end{macrocode}
% \textit{We jump back to the starting date and reset the
% human-side values.}
%    \begin{macrocode}
  \global\dates@date\cal@range@start%
  \caldate}%
%    \end{macrocode}
% Events are delimited by \cs{item}.
%    \begin{macrocode}
{\item}%
%    \end{macrocode}
% The next argument is dropped on DVI for each item.
% We use it here to fetch the text of appointments and
% events to the standard list macros, using the
% standard text-fetching commands.  Each generates a
% stack delimited by the phrase that was set above.
%    \begin{macrocode}
{\cal@get@appointments\cal@get@events}%
%    \end{macrocode}
% This sets \cs{cal@entry@text}.  It is executed for every
% event or appointment in the database that applies
% to a given item.  We differentiate between whole-day events,
% pinpointed events and ranged events.
%    \begin{macrocode}
{\relax%
   \ifnum\dates@time@start>0\relax%
    \ifnum\dates@time@start=\dates@time@end%
      \protected@edef\cal@entry@text{%
        \thetimestart\space%
        \cal@textcolor{\calcolor}{\thelongtext}}%
    \else%
      \protected@edef\cal@entry@text{%
        \thetimestart--\thetimeend\space%
        \cal@textcolor{\calcolor}{\thelongtext}}%
    \fi%
  \else%
      \protected@edef\cal@entry@text{%
        \cal@textcolor{\calcolor}{\thelongtext}}%
  \fi}%
%    \end{macrocode}
% Finally ...
%    \begin{macrocode}
{\ifcat$\theevents\theappointments$\else%
\el@maybeitem%
\el@maybeheader%
\fi%
\bgroup%
\let\item\par%
\ifcat$\theevents$\else%
  \par%
  \theevents%
\fi%
\egroup%
\ifcat$\theappointments$\else%
\begin{itemize}%
\item%
\theappointments%
\end{itemize}%
\fi}
%</style>
%    \end{macrocode}
% \Finale \PrintChanges
