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

  1. PROCEDURE dateNtimeStamp(hardcopy   : BOOLEAN;
  2.              VAR device : TEXT);
  3. {
  4. written by G.M.ACLAND
  5. COMMENT :
  6.     Prints the date and the time as in the following example :
  7.             MONDAY OCTOBER 21 1999  13:25:01
  8. If hardcopy is true then output will be to the file "device",otherwise 
  9. output will be to the terminal.The following external routines are called :
  10. PROCEDURES setlength,time,date,name_date and zeller &
  11. FUNCTIONS  weekday#,dig2integer,str2integer,length and mid .
  12. They , and their appropriate types and variables (n.b. especially the record
  13. type "composite" ) , must be declared in the main program as must be the 
  14. following types :
  15.     str8 = STRING 8;str9 = STRING 9;str10 = STRING 10;
  16. Note that this procedure was written primarily to use the clock chip
  17. ( OKI MSM5832 ) on the Godbout SS1 Board , via the time and date routines.
  18. However it does not depend on that chip.Any other way of supplying the time 
  19. and date in the correct format will do.Note also that if the date routine
  20. supplies a value for the day of week number that is > 6 then the day of week 
  21. will be calculated using the zeller procedure.
  22. Note also that it is set up assuming that the date is in the 20th Century.If 
  23. that is not true then a small change will be needed or code added to allow a
  24. differrent century to supplied from outside this procedure.
  25. Note also that the cursor or printhead is left at the end of the time and
  26. date stamp (i.e.no carriage return appended).            }
  27.  
  28. TYPE
  29.     str4        = STRING 4;
  30.  
  31. VAR
  32.     timestring    : str8;
  33.     yearname    : str4;
  34.     monthname,
  35.     dayname        : str9;
  36.     datestring    : str10;
  37.     ok        : BOOLEAN;
  38.     error#,
  39.     month#,
  40.     year#,
  41.     day#,
  42.     day_of_week    : INTEGER;
  43.     zeller#        : composite;
  44.  
  45. BEGIN
  46.  timestring := '  :  :  ';
  47.  datestring := '  /  /19  ';
  48.  time(timestring);
  49.  date(datestring,day_of_week);
  50.  monthname := mid(datestring,1,2);
  51.  ok       := str2integer(monthname,month#,error#);
  52.  dayname   := mid(datestring,4,5);
  53.  ok       := str2integer(dayname,day#,error#);
  54.  yearname  := mid(datestring,7,10);
  55.  ok       := str2integer(yearname,year#,error#);
  56.  name_date(month#,day#,year#,day_of_week,monthname,dayname);
  57.  IF hardcopy
  58.   THEN WRITE(device,dayname,' ',monthname,day#:3,' ',yearname,'  ',timestring)
  59.   ELSE WRITE(dayname,' ',monthname,day#:3,' ',yearname,'  ',timestring);
  60. END; { of : PROCEDURE dateNtimeStamp }
  61.