% \iffalse
% File: schedule.dtx Copyright (C) 1997-2001 Jason Alexander
%
% \fi
%         \ProvidesFile{schedule.dtx}
%          [1997/10/28 v1.0 `schedule' package (JMA)]
%
% \def\fileversion{v1.00}
% \def\filedate{1997/10/28}
%
% \iffalse
%<*driver>
\documentclass{ltxdoc}
\usepackage{schedule}
\CodelineIndex
\EnableCrossrefs
\RecordChanges
\begin{document}
 \DocInput{schedule.dtx} \PrintIndex \PrintChanges
\end{document}
%</driver>
%\fi
% \MakeShortVerb{\|}
%
% \changes{v1.00}{1997/10/11}{Initial version.}
%
% \title{The \textsf{schedule} package\thanks{This file
%        has version number \fileversion, last
%        revised \filedate.}}
% \author{Jason Alexander\footnote{Please send bug reports to:
%         \texttt{jalex@ea.oac.uci.edu}}}
% \date{\filedate}
% \maketitle
% \hfuzz=72pt
% \vfuzz=36pt
%
% \MakeShortVerb{\|}
%
% \begin{abstract}
% A new environment, {\ttfamily schedule}, is defined.  Primarily intended for
% constructing charts of recurring weekly appointments, the environment may also
% be used to create a schedule of events and sign-up sheets (for example,
% scheduling mandatory office visits with students for discussing paper topics,
% etc.)
%
% This package requires the packages {\ttfamily calc} and {\ttfamily color}.
% \end{abstract}
%
% \section{Introduction}
% \texttt{schedule} provides a simple interface for creating graphical charts
% displaying weekly appointments.  Many respects of the overall layout can be
% customized to suit the user's desires.  Unless these default settings are
% changed, the created schedule will run from Monday to Friday, 8:00am to 5:00pm,
% and the only predefined command to insert appointments will be |\class|, which
% draws the appointment using black text on a medium-gray background.
%
% The main feature of the \texttt{schedule} package is its accuracy in
% diagramming the length of appointments.  Unlike some professionally available
% schedule creation programs, the representation of the length of appointments in
% the \texttt{schedule} package is accurate to the minute.  In other
% words, if you have two appointments, one running from 2:00pm to 3:30pm on
% Tuesday and another running from 2:00pm to 3:31pm on Wednesday, there is a
% visible difference between the two representations.  Unfortunately, unless you
% have a high-resolution printer (by which I mean more than 600 dpi) these
% differences will likely only be noticeable by a on-screen previewing program like
% \texttt{ghostview}.
%
% \section{Examples}
%
% The following schedule is typeset using the commands:
%
% \pagebreak
%
% \begin{verbatim}
% \CellHeight{.4in}
% \CellWidth{1in}
% \TimeRange{12:00-15:00}
% \SubUnits{30}
% \BeginOn{Monday}
% \TextSize{\tiny}
% \FiveDay
%
% \NewAppointment{meeting}{red}{white}
% \NewAppointment{workshop}{green}{blue}
%
% \begin{schedule}[Fall Quarter, 1997]
%   \class{Moral Philosophy}{HOB2 233}{M}{14:00-16:50}
%   \class{Math Logic}{EIC 128}{T,Th}{11:00-12:20}
%   \class{Critical Reasoning}{SSL 290}{M,W,F}{13:00-13:50}
%   \meeting{Departmental Meeting}{HOB2 233}{W}{12:00-12:50}
%   \workshop{Crit. Reas. Workshop}{HOB2 233}{T}{13:00-13:50}
%   \class{Office Hours}{HOB2 210}{W,F}{14:00-14:50}
% \end{schedule}
% \end{verbatim}
%
% The result is:
% \CellHeight{.4in}
% \CellWidth{1in}
% \TimeRange{12:00-15:00}
% \SubUnits{30}
% \BeginOn{Monday}
% \TextSize{\tiny}
% \FiveDay
%
% \NewAppointment{meeting}{red}{white}
% \NewAppointment{workshop}{green}{blue}
%
%\begin{schedule}[Fall Quarter, 1997]%
%  \class{Moral Philosophy}{HOB2 233}{M}{14:00-16:50}
%  \class{Math Logic}{EIC 128}{T,Th}{11:00-12:20}
%  \class{Critical Reasoning}{SSL 290}{M,W,F}{13:00-13:50}
%  \meeting{Departmental Meeting}{HOB2 233}{W}{12:00-12:50}
%  \workshop{Crit. Reas. Workshop}{HOB2 233}{T}{13:00-13:50}
%  \class{Office Hours}{HOB2 210}{W,F}{14:00-14:50}
%\end{schedule}%
%
% This example demonstrates all of the user-customizable options.  Note
% several ``features'' of the package:
% \begin{enumerate}
%    \item Appointments falling outside of the specified time range
%          for the schedule are automatically truncated to fit.  If the
%          appointment falls entirely outside of the time range, it is not
%          printed at all.
%
%    \item The command |\class| is predefined to chart appointments pertaining
%          to class attendence.  New appointment types may be defined by the
%          user via the |\NewAppointment| command.  The new appointments may
%          use any predefined color for the text or background.  Note that the
%          \textsf{color} package allows one to define new colors.
%
%    \item The boxes created to represent appointments are sized to be
%          accurate to the minute.  In other words, if you have two
%          appointments, one 52 minutes long and the other 53 minutes long, the
%          box representing the second appointment will be slightly longer.
%
%    \item The schedule is typeset in a centered displayed environment.
% \end{enumerate}
%
% \section{User Commands}
%
% \begin{macro}{\CellHeight}
% Including |\CellHeight|\meta{length} before the \textsf{schedule} environment
% tells \LaTeXe\ what height to make the cells in the schedule (all cells have
% the same height).  Since a
% cell corresponds to an hour in the schedule, this command allows the user to
% specify how much vertical space a single hour ought to take up.
% \end{macro}
%
% \begin{macro}{\CellWidth}
% Including |\CellWidth|\meta{width} before the \textsf{schedule} environment
% tells \LaTeXe\ how wide to make every cell in the schedule.  The overall
% width of the schedule is determined by multiplying this value by the number of
% days (set by the |\FiveDay| or |\SevenDay| command), plus the width of the
% time labels on the left-hand side.
% \end{macro}
%
% \begin{macro}{\TimeRange}
% This command must appear before the \textsf{schedule} environment, otherwise
% \LaTeXe\ will not know how deep to make the grid.  It is important to note
% that the time range is specified using a 24-hour format, with a \emph{single}
% hyphen between the two times.  Deviating from this format will generate an
% error.
% \end{macro}
%
% \begin{macro}{\SubUnits}
% The |\SubUnits|\meta{number} tells the package how to subdivide the hour.  If
% one does not want any subdivisions, simply use |\SubUnits{60}|.  The value of
% \meta{number} can be any number than evenly divides 60.  It is assumed that,
% in specifying this value, you know what you are doing: i.e., if you tell
% \LaTeXe\ to use a |\CellHeight| of 1in, but then set |\SubUnits{3}|, you will
% get 20 subdivisions (with times) in a cell only 1in high.  In other words, the
% text on the left-hand side of the schedule will be typeset as a horrible mess.
% The solution is simple: if you want a large number of subdivisions, simply set
% |\CellHeight| to a greater value.
% \end{macro}
%
% \begin{macro}{\BeginOn}
% Including |\BeginOn|\meta{day} tells \LaTeX\ what day of the week to start
% the schedule on.  The possible values are `Sunday', `Monday', `Tuesday', `Wednesday',
% `Thursday', `Friday', or `Saturday'.  My apologies for non-English speaking
% users of \LaTeX.  If there is a demand for it, I will fix this in future
% releases.
% \end{macro}
%
% \begin{macro}{\TextSize}
% With the |\TextSize|\meta{font-size} command, the user tells \LaTeX\ what
% size font to use when typesetting the text inside the boxes.  This command
% ought to be one of the standard \LaTeX\ font-size commands, e.g., |\tiny|,
% |\scriptsize|, etc.  Using two large of a font will almost always result in
% bad line breaks inside the boxes, though, due to the narrow width of a cell.
% \end{macro}
%
% \begin{macro}{\FiveDay}
% Tells \LaTeX\ to typeset a five-day schedule.
% \end{macro}
%
% \begin{macro}{\SevenDay}
% Tells \LaTeX\ to typeset a seven-day schedule.
% \end{macro}
%
% \begin{macro}{\NewAppointment}
% By using the |\NewAppointment| command, the user can customize the appearance
% of the schedule by changing the color of the text or the background color.
% The syntax is |\NewAppointment|\meta{appointment-name}\meta{background-color}\meta{text-color}.
% \end{macro}
%
% \StopEventually{}
%
% \section{The Macros}
%
% \DoNotIndex{\if,\else,\fi,\expandafter}
% \DoNotIndex{\csname,\endcsname}
% \DoNotIndex{\addtocounter,\stepcounter,\advance,\Alph,\alph,\arabic}
% \DoNotIndex{\begin,\end,\begingroup,\endgroup,\catcode,\centerline,\day,\def}
% \DoNotIndex{\divide,\do,\edef,\endgroup,\evensidemargin,\fbox,\gdef,\global}
% \DoNotIndex{\headheight,\headsep,\hfill,\hphantom,\Huge,\ifnum,\ifx,\large}
% \DoNotIndex{\long,\m@ne,\mbox,\medskip,\message,\month,\multiply}
% \DoNotIndex{\noindent,\nopagebreak,\normalsize,\oddsidemargin,\pagebreak}
% \DoNotIndex{\par,\relax,\rightmargin,\roman,\setcounter,\setlength}
% \DoNotIndex{\smallskipamount,\space,\textheight,\textsf,\textwidth}
% \DoNotIndex{\the,\topmargin,\undefined,\underline,\value,\vspace}
% \DoNotIndex{\xdef,\year,\z@,\time,\topsep}
%
%    \begin{macrocode}
%<*header>
\ProvidesFile{schedule.dtx}
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{schedule}
\RequirePackage{calc}
\RequirePackage{color}
%</header>
%    \end{macrocode}
%
%    \begin{macrocode}
%<*package>
%    \end{macrocode}
%
%    \begin{macrocode}
\definecolor{dark}{gray}{.75}
%
% CONSTANTS FOR THE WEEK
%
\def\@sunday{Su}
 \def\@Sunday{Sunday}
\def\@monday{M}
 \def\@Monday{Monday}
\def\@tuesday{T}
 \def\@Tuesday{Tuesday}
\def\@wednesday{W}
 \def\@Wednesday{Wednesday}
\def\@thursday{Th}
 \def\@Thursday{Thursday}
\def\@friday{F}
 \def\@Friday{Friday}
\def\@saturday{Sa}
 \def\@Saturday{Saturday}
%
% COUNTERS, LENGTHS, ETC.
%
\newlength{\cell@height}
 \setlength{\cell@height}{1in}
\newlength{\cell@width}
 \setlength{\cell@width}{1in}
\newlength{\box@depth}
\newcounter{sch@col@width} \setcounter{sch@col@width}{60}
\newlength{\box@width}
 \setlength{\box@width}{1in*(\value{sch@col@width}/60)}
\newlength{\col@width}
 \setlength{\col@width}{1in*(\value{sch@col@width}/60)}
\newlength{\sch@depth} \setlength{\sch@depth}{9in}
\newlength{\fill@length}
\newlength{\@temp@length}
\newlength{\@@temp@length}
\newlength{\line@thickness} % The thickness of the lines in the drawing
 \setlength{\line@thickness}{.4pt}
\newlength{\adjusted@cell@width}
\newlength{\adjusted@cell@height}

\newcounter{picture@units@wide}
\newcounter{xcoords}
\newcounter{ycoords}
\newcounter{timea}
\newcounter{timeb}
\newcounter{grid@width}
\newcounter{grid@height}
\newcounter{number@of@cells} % The number of VERTICAL cells
\newcounter{number@of@subcells}
\newcounter{number@of@days} % The number of days in the grid
\newcounter{dp@vlines} % The number of vertical lines actually needed is
                       % \value{number@of@days} + 1 ...
\newcounter{dp@hlines} % The number of horizontal lines actually needed is
                       % \value{number@of@cells} + 1 ...
\newcounter{dp@hcell@lines} % The number of horizontal lines that are
                       % either (1) associated with an hour, or
                       %        (2) on the top or bottom of the grid.
\newcounter{pu@cell@width}
\newcounter{pu@cell@height}
 \setcounter{pu@cell@height}{60}
\newcounter{pu@grid@top}
\newcounter{pu@grid@width}
\newcounter{pu@subticks}
\newcounter{start@time}
\newcounter{end@time}
\newcounter{x@coord} % Temporary x-coordinate
\newcounter{y@coord} % Temporary y-coordinate
\newcounter{@tempc}
\newcounter{@tempd}
\newcounter{label@sep}  % distance from label to gride
 \setcounter{label@sep}{5} %initialized to 5 picture units

\newcounter{x@Sunday}
\newcounter{x@Monday}
\newcounter{x@Tuesday}
\newcounter{x@Wednesday}
\newcounter{x@Thursday}
\newcounter{x@Friday}
\newcounter{x@Saturday}

\newsavebox{\temp@box}
\newif\ifweekends
\newcount\@i
\newcount\@j

\def\TimeRange#1{\compute@number@of@cells #1\end@compute}
\def\compute@number@of@cells#1:#2-#3:#4\end@compute{%
  \setcounter{number@of@cells}{#3-#1}%
  \setcounter{start@time}{#1}%
  \setcounter{end@time}{#3}}

\def\TextSize#1{\def\appt@textsize{#1}}
\TextSize{\scriptsize}

\def\IncludeWeekends{\weekendstrue}
\def\NoWeekends{\weekendsfalse}

\def\SevenDay{\weekendstrue}
\def\FiveDay{\weekendsfalse}

\def\CellHeight#1{\setlength{\cell@height}{#1}%
                  \setlength{\unitlength}{\cell@height*\ratio{1pt}{60pt}}}
\def\CellWidth#1{\setlength{\cell@width}{#1}%
                 \setcounter{pu@cell@width}{1*\ratio{\cell@width}{\unitlength}}}
\def\SubUnits#1{\setcounter{pu@subticks}{#1}%
                \setcounter{number@of@subcells}{60/\value{pu@subticks}}}

\def\calculate@grid@dimensions{%
  \ifweekends \setcounter{number@of@days}{7}
   \else \setcounter{number@of@days}{5}%
    \fi%
  \setcounter{dp@hcell@lines}{\value{number@of@cells}+1}
  \setcounter{grid@width}{\value{number@of@days}*\value{pu@cell@width}}%
  \setcounter{grid@height}{\value{number@of@cells}*60}
  \setcounter{dp@vlines}{\value{number@of@days}+1}
  \setcounter{dp@hlines}{\value{number@of@cells}*(60/\value{pu@subticks}) + 1}}


\def\draw@grid{%\calculate@grid@dimensions
  \linethickness{.2pt}%
  \multiput(0,0)(0,\value{pu@subticks}){\value{dp@hlines}}{\line(1,0){\value{grid@width}}}%
  \thicklines
  \multiput(0,0)(0,60){\value{dp@hcell@lines}}{\line(1,0){\value{grid@width}}}
  \thinlines}

\def\LineThickness#1{\setlength{\line@thickness}{#1}%
                     \linethickness{\line@thickness}%
                     \setlength{\adjusted@cell@width}{\cell@width - 1\line@thickness}
                     \setlength{\adjusted@cell@height}{\cell@height - 1\line@thickness}}


\def\@Su@week{{Sunday} {Monday} {Tuesday} {Wednesday} {Thursday} {Friday} {Saturday}}
\def\@M@week{{Monday} {Tuesday} {Wednesday} {Thursday} {Friday} {Saturday} {Sunday}}
\def\@T@week{{Tuesday} {Wednesday} {Thursday} {Friday} {Saturday} {Sunday} {Monday}}
\def\@W@week{{Wednesday} {Thursday} {Friday} {Saturday} {Sunday} {Monday} {Tuesday}}
\def\@Th@week{{Thursday} {Friday} {Saturday} {Sunday} {Monday} {Tuesday} {Wednesday}}
\def\@F@week{{Friday} {Saturday} {Sunday} {Monday} {Tuesday} {Wednesday} {Thursday}}
\def\@Sa@week{{Saturday} {Sunday} {Monday} {Tuesday} {Wednesday} {Thursday} {Friday}}

\def\BeginOn#1{\def\start@day{#1}}

\def\add@labels{%
 \ifx\start@day\@Sunday \expandafter\do@days\@Su@week \relax
  \else\ifx\start@day\@Monday \expandafter\do@days\@M@week \relax
   \else\ifx\start@day\@Tuesday \expandafter\do@days\@T@week \relax
    \else\ifx\start@day\@Wednesday \expandafter\do@days\@W@week \relax
     \else\ifx\start@day\@Thursday \expandafter\do@days\@Th@week \relax
      \else\ifx\start@day\@Friday \expandafter\do@days\@F@week \relax
       \else\expandafter\do@days\@Sa@week \relax
    \fi\fi\fi\fi\fi\fi}


\def\@sfor #1:=#2 \upto #3 \step #4 \do #5{%
  #1=#2\relax%
  \@whilenum #1<#3 \do {#5 \advance#1 by #4}#5}

\def\add@times{%
  \setcounter{@tempc}{\value{start@time}}%
  \@sfor \@i :=0 \upto \value{number@of@cells} \step 1 \do%
    {\setcounter{x@coord}{0}%                               Set the x-coord right
     \setcounter{y@coord}{\value{grid@height}-60*\@i}%      adjust for the right hour cell
     \ifnum\value{@tempc}>12%
        \setcounter{@tempd}{\value{@tempc}-12}%
        \put(\value{x@coord},\value{y@coord}){\makebox(0,0)[r]{\the@tempd:00 pm\ }}%
     \else\put(\value{x@coord},\value{y@coord}){\makebox(0,0)[r]{\the@tempc:00 am\ }}%
     \fi\relax%
     \@sfor \@j := \value{pu@subticks} \upto 59 \step \value{pu@subticks} \do%
       {\ifnum\@i=\value{number@of@cells}%  Test to see if this should be the last label
           \relax%
        \else%
           \ifnum\@j=60%
             \relax%
           \else%
             \ifnum\@j<10%
               \def\the@minutes{0\the\@j}%
             \else\def\the@minutes{\the\@j}%
             \fi%
             \setcounter{y@coord}{\value{y@coord}-\@j}%
             \ifnum\value{@tempc}>12%
                \setcounter{@tempd}{\value{@tempc}-12}%
                \put(\value{x@coord},\value{y@coord}){\makebox(0,0)[r]{\tiny\the@tempd:\the@minutes\ pm\ }}% ...write the time (using pm)...
             \else\put(\value{x@coord},\value{y@coord}){\makebox(0,0)[r]{\tiny\the@tempc:\the@minutes\ am\ }}% ...write the time (using am).
             \fi%
           \fi%
        \fi%
        \setcounter{y@coord}{\value{y@coord}+\@j}}
     \addtocounter{@tempc}{1}}}%

\def\do@days#1#2#3#4#5#6#7{%
  \setcounter{x@coord}{1*\ratio{\value{pu@cell@width} pt}{2 pt}}%
  \setcounter{y@coord}{\value{grid@height}+\value{label@sep}}%
  \put(\value{x@coord},\value{y@coord}){\makebox(0,0)[b]{\large #1}}%
  \setcounter{x@coord}{\value{x@coord}+\value{pu@cell@width}}%
  \put(\value{x@coord},\value{y@coord}){\makebox(0,0)[b]{\large #2}}%
  \setcounter{x@coord}{\value{x@coord}+\value{pu@cell@width}}%
  \put(\value{x@coord},\value{y@coord}){\makebox(0,0)[b]{\large #3}}%
  \setcounter{x@coord}{\value{x@coord}+\value{pu@cell@width}}%
  \put(\value{x@coord},\value{y@coord}){\makebox(0,0)[b]{\large #4}}%
  \setcounter{x@coord}{\value{x@coord}+\value{pu@cell@width}}%
  \put(\value{x@coord},\value{y@coord}){\makebox(0,0)[b]{\large #5}}%
  \setcounter{x@coord}{\value{x@coord}+\value{pu@cell@width}}%
  \ifweekends
  \put(\value{x@coord},\value{y@coord}){\makebox(0,0)[b]{\large #6}}%
  \setcounter{x@coord}{\value{x@coord}+\value{pu@cell@width}}%
  \put(\value{x@coord},\value{y@coord}){\makebox(0,0)[b]{\large #7}}\fi}


\def\set@x@coords@for@days{%
  \ifx\start@day\@Sunday%
    \@i=0\relax%
    \@tfor \@temp := {Sunday} {Monday} {Tuesday} {Wednesday} {Thursday} {Friday} {Saturday} \do%
      {\setcounter{x@\@temp}{\@i*\value{pu@cell@width}}%
       \advance\@i by 1}
    \def\skipday@i{F}
    \def\skipday@ii{Sa}\fi
  \ifx\start@day\@Monday
    \@i=0\relax%
    \@tfor \@temp := {Monday} {Tuesday} {Wednesday} {Thursday} {Friday} {Saturday} {Sunday} \do%
      {\setcounter{x@\@temp}{\@i*\value{pu@cell@width}}%
       \advance\@i by 1}
    \def\skipday@i{Sa}
    \def\skipday@ii{Su}\fi
  \ifx\start@day\@Tuesday
    \@i=0\relax%
    \@tfor \@temp := {Tuesday} {Wednesday} {Thursday} {Friday} {Saturday} {Sunday} {Monday} \do%
      {\setcounter{x@\@temp}{\@i*\value{pu@cell@width}}%
       \advance\@i by 1}
    \def\skipday@i{Su}
    \def\skipday@ii{M}\fi
  \ifx\start@day\@Wednesday
    \@i=0\relax%
    \@tfor \@temp := {Wednesday} {Thursday} {Friday} {Saturday} {Sunday} {Monday} {Tuesday} \do%
      {\setcounter{x@\@temp}{\@i*\value{pu@cell@width}}%
       \advance\@i by 1}
    \def\skipday@i{M}
    \def\skipday@ii{T}\fi
  \ifx\start@day\@Thursday
    \@i=0\relax%
    \@tfor \@temp := {Thursday} {Friday} {Saturday} {Sunday} {Monday} {Tuesday} {Wednesday} \do%
      {\setcounter{x@\@temp}{\@i*\value{pu@cell@width}}%
       \advance\@i by 1}
    \def\skipday@i{T}
    \def\skipday@ii{W}\fi
  \ifx\start@day\@Friday
    \@i=0\relax%
    \@tfor \@temp := {Friday} {Saturday} {Sunday} {Monday} {Tuesday} {Wednesday} {Thursday} \do%
      {\setcounter{x@\@temp}{\@i*\value{pu@cell@width}}%
       \advance\@i by 1}
    \def\skipday@i{W}
    \def\skipday@ii{Th}\fi
  \ifx\start@day\@Saturday
    \@i=0\relax%
    \@tfor \@temp := {Saturday} {Sunday} {Monday} {Tuesday} {Wednesday} {Thursday} {Friday} \do%
      {\setcounter{x@\@temp}{\@i*\value{pu@cell@width}}%
       \advance\@i by 1}
    \def\skipday@i{Th}
    \def\skipday@ii{F}\fi
  }

% ------------------------------------------------------------------------
% Commands to insert info about an appointment
% ------------------------------------------------------------------------
\newif\ifset@start@time
\newif\ifset@end@time
\newif\ifsetboxdepth
\newif\ifinrange

\def\NewAppointment#1#2#3{% #1 = name, #2 = background color, #3 = textcolor
  \expandafter\def\csname #1\endcsname##1##2##3##4{%
     \setboxdepthtrue% assume we want to calculate the box depth
     \inrangetrue% assume the appt is in range
     \set@start@timetrue% assume we want to calculate the start time
     \set@end@timetrue% assume we want to calculate the end time
     \@includetrue% assume we will include it
     \edef\appt@name{#1}% save the appt name
     \edef\appt@color{#2}% save the background color
     \edef\appt@textcolor{#3}% save the save color
     \expandafter\def\csname #1@name\endcsname{##1}% save the name
     \expandafter\def\csname #1@location\endcsname{##2}% save the loc.
     \expandafter\def\csname #1@days\endcsname{##3}% save the days
     \expandafter\def\csname #1@time\endcsname{##4}% save the time
     \place@appt@box##3,\stop}}

\NewAppointment{class}{dark}{black}

\def\place@appt@box#1{%
  \ifx#1\stop \let\@next=\@gobble%
   \else \let\@next=\set@x@coords\fi\@next#1}

\def\set@x@coords#1,{\def\the@day{#1}%
 \ifx\the@day\@sunday\setcounter{xcoords}{\value{x@Sunday}}%
  \else\ifx\the@day\@monday\setcounter{xcoords}{\value{x@Monday}}%
   \else\ifx\the@day\@tuesday\setcounter{xcoords}{\value{x@Tuesday}}%
    \else\ifx\the@day\@wednesday\setcounter{xcoords}{\value{x@Wednesday}}%
     \else\ifx\the@day\@thursday\setcounter{xcoords}{\value{x@Thursday}}%
      \else\ifx\the@day\@friday\setcounter{xcoords}{\value{x@Friday}}%
       \else\setcounter{xcoords}{\value{x@Saturday}}%
        \fi\fi\fi\fi\fi\fi%
         \edef\@@temp{\csname \appt@name @time\endcsname}%
          \expandafter\set@y@coords\@@temp\stop}

\def\set@y@coords#1:#2-#3:#4\stop{%
  \def\@starthour{#1}%
  \def\@startminutes{#2}
  \def\@endhour{#3}%
  \def\@endminutes{#4}%
  \ifnum#1<\value{start@time} \setcounter{ycoords}{\value{grid@height}}%
                              \edef\@starthour{\value{start@time}}
                              \def\@startminutes{0}
                              \set@start@timefalse%
                              \fi%
  \ifnum#3<\value{end@time} \relax%
    \else \edef\@endhour{\value{end@time}}
          \def\@endminutes{0}%
          \setcounter{ycoords@bot}{0}
          \set@end@timefalse
  \fi %
  \ifset@start@time%
   \setcounter{ycoords}{\value{grid@height}-(60*(#1-\value{start@time})+#2)}\fi%
  \ifset@end@time%
    \setcounter{ycoords@bot}{\value{grid@height}-(60*(#3-\value{start@time})+#4)}\fi%
  \setlength{\box@depth}{\@endhour\cell@height + (\cell@height*\ratio{\@endminutes pt}{60pt}) %
         - \@starthour\cell@height - (\cell@height*\ratio{\@startminutes pt}{60pt})}%
  \ifnum#1<\value{end@time} \relax\else \inrangefalse \fi%
  \draw@appt@box\place@appt@box}

\newif\if@include

\def\draw@appt@box{%
   \ifweekends \relax % if we use 7-days, this won't change
   \else \ifx \the@day\skipday@i \@includefalse \fi % first condition for change
         \ifx \the@day\skipday@ii \@includefalse \fi\fi % second condition for change
  \ifinrange \relax\else \@includefalse \fi %
  \if@include %
  \put(\value{xcoords},\value{ycoords}){\colorbox{\appt@color}{\parbox[t]{\cell@width}{\ %
        \vspace{\box@depth}}}}
  \thinlines
  \put(\value{xcoords},\value{ycoords}){\line(1,0){\value{pu@cell@width}}}
  \put(\value{xcoords},\value{ycoords@bot}){\line(1,0){\value{pu@cell@width}}}
  \put(\value{xcoords},\value{ycoords}){%
        \  \parbox[t]{\cell@width-8pt}{\mbox{}\\ \appt@textsize %
        \ifdim\box@depth>\baselineskip
        \textcolor{\appt@textcolor}{\csname \appt@name @name\endcsname} \\ %
        \ifdim\box@depth>2\baselineskip
        \textcolor{\appt@textcolor}{\csname \appt@name
        @location\endcsname}\fi\fi }}\fi}

\def\convert@class@time#1:#2-#3:#4\end@time{%
  {\count1=#1\relax%
   \count3=#3\relax%
   \ifnum#1>12 \advance\count1 by -12\fi\relax%
   \ifnum#3>12 \advance\count3 by -12\fi\relax%
   \ifnum#1<12\relax%
    \ifnum#3<12\relax \mbox{\the\count1:#2am--\the\count3:#4am}\relax%
     \else \mbox{\the\count1:#2am--\the\count3:#4pm}\fi\relax%
      \else \mbox{\the\count1:#2pm--\the\count3:#4pm}\fi\relax}}

\def\compute@box@depth#1:#2-#3:#4\end@bx{%
  \setlength{\box@depth}{#3\cell@height + (\cell@height*\ratio{#4pt}{60pt}) %
         - #1\cell@height - (\cell@height*\ratio{#2pt}{60pt})}}

\newcounter{ycoords@bot}

\newcounter{x@tempa}
\newcounter{x@tempb}
\newcounter{y@tempa}
\newcounter{y@tempb}
\newcounter{temp@cnt@a}

\newlength{\title@height}
\newlength{\label@height}
 \settoheight{\label@height}{Wednesday}

\newcounter{pu@label@width}
\newlength{\center@hack}

\newenvironment{schedule}[1][:]%
{\bigskip
 \calculate@grid@dimensions%
 \setcounter{pu@grid@width}{\value{pu@cell@width}*\value{number@of@days}}%
 \settowidth{\@temp@length}{\normalsize 12:00\ pm\ }%
 \setcounter{pu@label@width}{1*\ratio{\@temp@length}{\unitlength}}%
 \setcounter{pu@grid@top}{\value{grid@height}+(1*\ratio{\label@height}{\unitlength}) + %
    (1*\ratio{.25in}{\unitlength})}%
 \if#1:\relax \else%
  \settoheight{\title@height}{\large #1}%
  \addtocounter{pu@grid@top}{1*\ratio{\title@height}{\unitlength}}%
 \fi%
 \setlength{\center@hack}{(.5\linewidth-.5\unitlength*\value{pu@grid@width}+%
   .5\unitlength*\value{pu@label@width})}%
 \noindent\hspace*{\center@hack}%
 \begin{picture}(\value{pu@grid@width},\value{pu@grid@top})%
 \draw@grid
 \add@labels
 \if#1:\relax \else
  \setcounter{ycoords}{\value{grid@height}+(1*\ratio{\label@height}{\unitlength}) + %
     (1*\ratio{.25in}{\unitlength})}
  \setcounter{xcoords}{1*\ratio{\value{pu@grid@width} pt}{2 pt}}
 \put(\value{xcoords},\value{ycoords}){\makebox(0,0)[b]{\Large #1}}
 \fi
 \add@times
 \set@x@coords@for@days}
{\multiput(0,0)(\value{pu@cell@width},0){\value{dp@vlines}}{\line(0,1){\value{grid@height}}}
 \end{picture}\bigskip}

\setlength{\fboxsep}{0in}
%\pagestyle{empty}
%    \end{macrocode}
%
%    \begin{macrocode}
%</package>
%    \end{macrocode}
%
% \Finale \PrintChanges