home *** CD-ROM | disk | FTP | other *** search
/ Oakland CPM Archive / oakcpm.iso / sigm / vol131 / namedate.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1984-04-29  |  1.6 KB  |  55 lines

  1. PROCEDURE NAME_DATE(    m,
  2.             d,
  3.             y     : INTEGER;
  4.         VAR day_of_week    : INTEGER;
  5.         VAR monthname,
  6.             dayname    : STR9 );
  7. { COMMENT:
  8.     Namedate accepts as input the date expressed as a set of integers.
  9.     The month and day of the week will be named and returned in the
  10.     corresponding strings.
  11.     If the calling program transmits a number between 0 and 6 in the
  12.     variable day_of_week , then this is assumed to be the day number,
  13.     otherwise the day number will be determined using the zeller#
  14.     algorithm , via the PROCEDURE weekday#.
  15.     Note that if the zeller# is to be determined , then the number
  16.     for the year must be complete (e.g. 1982 ,not 82).
  17.     If something screws up and the day of week number or the month
  18.     number ends up out of range , then the appropriate string will
  19.     return as 'ERROR'.
  20. }
  21. VAR
  22.     day#        : INTEGER;
  23.  
  24. BEGIN
  25. writeln;
  26.  IF day_of_week IN [0..6]
  27.     THEN day# := day_of_week
  28.     ELSE day# := weekday#(m,d,y);
  29.  CASE day# OF
  30.   0    : dayname := 'SUNDAY';
  31.   1    : dayname := 'MONDAY';
  32.   2    : dayname := 'TUESDAY';
  33.   3    : dayname := 'WEDNESDAY';
  34.   4    : dayname := 'THURSDAY';
  35.   5    : dayname := 'FRIDAY';
  36.   6    : dayname := 'SATURDAY';
  37.   ELSE    : dayname := 'ERROR'
  38.   END;
  39.  CASE m OF
  40.   1     : monthname := 'JANUARY';
  41.   2     : monthname := 'FEBRUARY';
  42.   3     : monthname := 'MARCH';
  43.   4     : monthname := 'APRIL';
  44.   5     : monthname := 'MAY';
  45.   6     : monthname := 'JUNE';
  46.   7     : monthname := 'JULY';
  47.   8     : monthname := 'AUGUST';
  48.   9     : monthname := 'SEPTEMBER';
  49.   10    : monthname := 'OCTOBER';
  50.   11    : monthname := 'NOVEMBER';
  51.   12    : monthname := 'DECEMBER';
  52.   ELSE  : monthname := 'ERROR'
  53.   END;
  54. END; { of : PROCEDURE namedate }
  55.