home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Media Share 9
/
MEDIASHARE_09.ISO
/
pascal
/
tplib21.zip
/
INSTALL.EXE
/
EXTIME.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1993-05-30
|
4KB
|
112 lines
(* Example program: TIME unit *)
PROGRAM EXTIME;
USES
STRINGS, TIME;
VAR
s: STRING;
PROCEDURE ExOpt1;
VAR
d: DateRec;
BEGIN
WriteLn ('At each prompt enter a string that represents a date. The');
WriteLn ('DateParse function is used to convert your input to a date');
WriteLn ('record and the program then shows examples of formatted');
WriteLn ('output. Enter "Q" to exit.');
DateDelimiter := '-';
REPEAT
WriteLn;
Write ('Enter date : ');
ReadLn(s);
IF UpperCase(s)='Q' THEN EXIT;
IF DateParse(s,d) THEN
BEGIN
WriteLn ('Date accepted');
DateFormat := DateFormNumeric;
WriteLn('Numeric format = "', DateStr(d), '"');
DateFormat := DateFormAlpha;
WriteLn('Alphabetic format = "', DateStr(d), '"');
DateFormat := DateFormMDY;
WriteLn('MDY format = "', DateStr(d), '"');
DateFormat := DateFormDMY;
WriteLn('DMY format = "', DateStr(d), '"');
DateFormat := DateFormNumeric;
FullDateFormat := FullDateFormMDY;
WriteLn('Full format MDY = "', FullDateStr(d), '"');
FullDateFormat := FullDateFormDMY;
WriteLn('Full format DMY = "', FullDateStr(d), '"');
WriteLn('Day = "',
DayOfWeekStr(DayOfWeek(DateToWord(d))),'"');
END
ELSE
WriteLn ('Cannot convert typed string to date - Try again');
UNTIL FALSE;
END; { ExOpt1 }
PROCEDURE ExOpt2;
VAR
t: TimeRec;
BEGIN
WriteLn ('At each prompt enter a string that represents a time. The');
WriteLn ('TimeParse function is used to convert your input to a time');
WriteLn ('record and the program then shows examples of formatted');
WriteLn ('output. Enter "Q" to exit.');
REPEAT
WriteLn;
Write('Input time: ');
ReadLn(s);
IF UpperCase(s)='Q' THEN EXIT;
IF TimeParse(s,t) THEN
BEGIN
TimeFormat:=TimeFormNormal;
WriteLn('TimeFormNormal = "',TimeStr(t),'"');
TimeFormat:=TimeFormNormalSec;
WriteLn('TimeFormNormalSec = "',TimeStr(t),'"');
TimeFormat:=TimeFormShort;
WriteLn('TimeFormShort = "',TimeStr(t),'"');
TimeFormat:=TimeFormShortSec;
WriteLn('TimeFormShortSec = "',TimeStr(t),'"');
TimeFormat:=TimeFormMilitary;
WriteLn('TimeFormMilitary = "',TimeStr(t),'"');
TimeFormat:=TimeFormMilitarySec;
WriteLn('TimeFormMilitarySec = "',TimeStr(t),'"');
TimeFormat:=TimeFormMilitaryHHMM;
WriteLn('TimeFormMilitaryHHMM = "',TimeStr(t),'"');
END
ELSE
WriteLn('Cannot convert typed string - Try again.');
UNTIL FALSE;
END; { ExOpt2 }
BEGIN { ExTime }
WriteLn('EXTIME - TIME UNIT EXAMPLE PROGRAM');
WriteLn;
REPEAT
WriteLn;
WriteLn('Select the features you wish to try:');
WriteLn;
WriteLn(' 1. Date parsing.');
WriteLn(' 2. Time parsing');
WriteLn;
Write('Enter option or zero to quit : ');
ReadLn(s);
s:=TrimL(s);
WriteLn;
CASE s[1] OF
'1': ExOpt1;
'2': ExOpt2;
END;
UNTIL s[1]='0';
END.