home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / listings / v_01_02 / 1n02037b < prev    next >
Text File  |  1990-07-09  |  1KB  |  56 lines

  1.  
  2. ----------
  3.  
  4. const
  5.     WEEKS_PER_MONTH = 6;
  6.  
  7. type
  8.     month = (JAN, FEB, MAR, APR, MAY, JUN,
  9.         JUL, AUG, SEP, OCT, NOV, DEC);
  10.     day = (SUN, MON, TUE, WED, THU, FRI, SAT);
  11.  
  12. type
  13.     monthly_calendar =
  14.         array [1..WEEKS_PER_MONTH, day] of integer;
  15.     annual_calendar
  16.         = array [month] of monthly_calendar;
  17.  
  18. {*
  19.  * write a monthly calendar
  20.  *}
  21. procedure write_monthly(var cal : monthly_calendar);
  22.     var
  23.         d : day
  24.         w : integer;
  25.     begin
  26.     for w := 1 to WEEKS_PER_MONTH do
  27.         begin
  28.         for d := SUN to SAT do
  29.             if cal[w, d] > 0 then
  30.                 write(cal[w, d]:4)
  31.             else
  32.                 write(' ':4);
  33.         writeln;
  34.         end;
  35.     end;
  36.  
  37. {*
  38.  * return the number of week days in a month
  39.  *}
  40. function monthly_week_days(var cal : monthly_calendar)
  41.         : integer;
  42.     var
  43.         d : day;
  44.         w, sum : integer;
  45.     begin
  46.     sum := 0;
  47.     for w := 1 to WEEKS_PER_MONTH do
  48.         for d := MON to FRI do
  49.             if cal[w, d] > 0 then
  50.                 sum := sum + 1;
  51.     monthly_week_days := sum;
  52.     end;
  53.  
  54. Listing 2 - Calendars in Pascal using Enumerations
  55.  
  56.