home *** CD-ROM | disk | FTP | other *** search
- PROGRAM get_time_and_date;
-
- VAR year,month,day : INTEGER;
- hour,minute,second : INTEGER;
-
- (* The following procedure can be included in any MSDOS/PCDOS
- program to get the present date and time. The present date
- and time can then be printed on your output to automatically
- time and date your output listings. Note that this is a TURBO
- Pascal extension and will probably not work with other Pascal
- compilers. This program uses some very advanced programming
- techniques requiring knowledge of some of the details of the
- DOS system. Don't worry if you don't understand all of this.
- *)
-
- PROCEDURE time_and_date(VAR year,month,day,hour,min,sec : integer);
-
- TYPE reg_definitions = RECORD
- AX,BX,CX,DX,BP,SI,DI,DS,ES,FLAGS : INTEGER;
- END;
-
- VAR registers : reg_definitions;
-
- BEGIN
- registers.AX := $2A SHL 8; (* get todays date *)
- msdos(registers);
- year := registers.cx;
- day := registers.dx MOD 256;
- month := registers.dx SHR 8;
-
- registers.AX := $2C SHL 8; (* get the time *)
- msdos(registers);
- hour := registers.cx SHR 8;
- min := registers.cx MOD 256;
- sec := registers.dx SHR 8;
- END;
-
- BEGIN
- time_and_date(year,month,day,hour,minute,second);
- WRITELN('The date is ',month:2,'/',day:2,'/',year);
- WRITELN('The time is ',hour:2,':',minute:2,':',second:2);
- END.