PROGRAM DayTime(Output);
    { Program 5.1 - Illustrate enumerated types. }
    TYPE
        Days = (Mon, Tue, Wed, Thu, Fri, Sat, Sun);
        When = (Past, Present, Future);
    VAR
        Day: Days;
        Yesterday, Today, Tomarrow: Days;
        Time: When;
BEGIN
    Today := Sun;   { | Pascal can't read a value of an     }
                    { | enumerated type from Input          }
    Time := Present;

    REPEAT
        CASE Time OF
        Present: BEGIN   { Calculate Yesterday }
            Time := Past;
            IF Today = Mon THEN
                Yesterday := Sun
            ELSE
                Yesterday := Pred(Today);
            Day := Yesterday;
            Write(Output, 'Yesterday ')
            END;
        Past: BEGIN      { Calculate Tommorow }
            Time := Future;
            IF Today = Sun THEN
                Tomarrow := Mon
            ELSE
                Tomarrow := Succ(Today);
            Day := Tomarrow;
            Write(Output, 'Tomorrow ')
            END;
        Future: BEGIN    { Reset to Present }
            Time := Present;
            Day := Today;
            Write(Output, 'Today ')
            END
        END;

        CASE Day OF
        Mon: Write(Output, 'Monday');
        Tue: Write(Output, 'Tuesday');
        Wed: Write(Output, 'Wednesday');
        Thu: Write(Output, 'Thursday');
        Fri: Write(Output, 'Friday');
        Sat: Write(Output, 'Saturday');
        Sun: Write(Output, 'Sunday')
        END;

        WriteLn(Output, Ord(Time) - 1)
    UNTIL Time = Present
END.
