home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip 1997 April
/
Chip_1997-04_cd.bin
/
tema
/
602propc
/
disk12
/
data.12
/
WINTEXT
/
MAKRA
/
SOURCES
/
SETDATE.TXT
< prev
next >
Wrap
Text File
|
1996-12-17
|
5KB
|
184 lines
//***********************************************************************
//*
//* Nßzev makra:
//* Autor:
//* Datum vytvo°enφ:
//*
//* Nßzev souboru:
//* Nßzev programu:
//* Tisk:
//*
//* Popis:
//*
//*
//***********************************************************************
program Datum_a_Φas;
const
COUNT_F_DATE = 10;
COUNT_F_TIME = 7;
type
tSystemTime = record
wYear, wMonth, wDayOfWeek, wDay,
wHours, wMinutes, wSeconds, wMilliseconds : short;
end;
tFormat = record
iDate, iTime : short;
end;
strTxt = string[30];
var
sd : array[1..COUNT_F_DATE] of strTxt;
st : array[1..COUNT_F_TIME] of strTxt;
sMonth : array[1..12] of string[9];
sDay : array[0..6] of string[9];
function w2s( w : short ) : string[5];
begin
w2s := int2str(w);
end;
function addZero( w : short ) : string[2];
var s : string[2];
begin
s := int2str(w);
if (strlength(s) = 1) then s := "0" + s;
addZero := s;
end;
procedure init;
var
s : string[1];
t : tSystemTime;
dt : date;
tm : time;
frm : tFormat;
sYear2, sH, sM, sS, sH2 : string[2];
sOD : string[5];
len : short;
begin
sMonth[1] := 'leden';
sMonth[2] := '·nor';
sMonth[3] := 'b°ezen';
sMonth[4] := 'duben';
sMonth[5] := 'kv∞ten';
sMonth[6] := 'Φerven';
sMonth[7] := 'Φervenec';
sMonth[8] := 'srpen';
sMonth[9] := 'zß°φ';
sMonth[10] := '°φjen';
sMonth[11] := 'listopad';
sMonth[12] := 'prosinec';
sDay[0] := 'ned∞le';
sDay[1] := 'pond∞lφ';
sDay[2] := '·ter²';
sDay[3] := 'st°eda';
sDay[4] := 'Φtvrtek';
sDay[5] := 'pßtek';
sDay[6] := 'sobota';
// GetLocalTime( st );
dt := today;
tm := now;
t.wYear := Year(dt);
t.wMonth := Month(dt);
t.wDayOfWeek := Day_Of_week(dt);
t.wDay := Day(dt);
t.wHours := Hours(tm);
t.wMinutes := Minutes(tm);
t.wSeconds := Seconds(tm);
sYear2 := StrCopy(w2s(t.wYear), 3, 2);
sH := addZero(t.wHours);
if (t.wHours > 12)
then begin sH2 := int2str(t.wHours-12); sOD := ' odp.'; end
else begin sH2 := int2str(t.wHours); sOD := ' dop.'; end;
sM := addZero(t.wMinutes);
sS := addZero(t.wSeconds);
len := strlength(sMonth[t.wMonth]);
sd[1] := '';
sd[2] := w2s(t.wDay) + "." + w2s(t.wMonth) + "." + w2s(t.wYear);
sd[3] := w2s(t.wDay) + "." + w2s(t.wMonth) + "." + sYear2;
sd[4] := w2s(t.wMonth) + "." + w2s(t.wYear);
sd[5] := w2s(t.wDay) + "." + w2s(t.wMonth) + ".";
sd[6] := w2s(t.wDay) + ". " + sMonth[t.wMonth] + " " + sYear2;
sd[7] := w2s(t.wDay) + ". " + sMonth[t.wMonth] + " " + w2s(t.wYear);
s := ' ';
s := sMonth[t.wMonth][1];
sd[8] := UpCase(s) +
StrCopy(sMonth[t.wMonth],2,len-1) + " ''" + sYear2;
sd[9] := sDay[t.wDayOfWeek] + " " + w2s(t.wDay) + ". " +
sMonth[t.wMonth] + " " + w2s(t.wYear);
sd[10] := sDay[t.wDayOfWeek] + " " + w2s(t.wDay) + ". " +
sMonth[t.wMonth] + " " + sYear2;
st[1] := '';
st[2] := sH + ":" + sM + ":" + sS;
st[3] := sH + ":" + sM;
st[4] := int2str(t.wHours) + ":" + sM + ":" + sS;
st[5] := int2str(t.wHours) + ":" + sM;
st[6] := sH2 + ":" + sM + ":" + sS + sOD;
st[7] := sH2 + ":" + sM + sOD;
end;
function DoDlgFormat( var frm : tFormat ) : boolean;
const
idlDate = 101;
idlTime = 102;
var
dlg, id, i : short;
bResult : boolean;
begin
bResult := false;
{ vytvo°enφ dialogu : }
dlg := DialogCreate( 30, 40, 260, 110, 'Vlo₧enφ data a Φasu' );
DlgText( dlg, 'Formßt &data:', 201, 10, 10, 90 );
DlgListbox( dlg, false, idlDate, 10, 20, 90, 85 );
DlgText( dlg, 'Formßt Φ&asu:', 202, 110, 10, 90 );
DlgListbox( dlg, false, idlTime, 110, 20, 90, 85 );
DlgBtnOk( dlg, 210, 20, 40 );
DlgBtnCancel( dlg, 210, 40, 40 );
DlgButtonDefPush( dlg, IDOK, true );
{ napln∞nφ listbox∙ : }
DlgStrBoxAdd(dlg, idlDate, 1, '[₧ßdn²]');
DlgStrBoxAdd(dlg, idlTime, 1, '[₧ßdn²]');
for i:=2 to COUNT_F_DATE do DlgStrBoxAdd(dlg, idlDate, i, sd[i]);
for i:=2 to COUNT_F_TIME do DlgStrBoxAdd(dlg, idlTime, i, st[i]);
DlgStrBoxSetVal(dlg, idlDate, 2);
DlgStrBoxSetVal(dlg, idlTime, 2);
if (DialogRun( dlg ) = IDOK) then begin
frm.iDate := DlgStrBoxGetVal( dlg, idlDate );
frm.iTime := DlgStrBoxGetVal( dlg, idlTime );
bResult := true;
end;
DoDlgFormat := bResult;
end;
procedure run;
var frm : tFormat;
begin
if (DoDlgFormat(frm)) then begin
if (frm.iDate <> 1) and (frm.iTime <> 1) then
sd[frm.iDate] := sd[frm.iDate] + " ";
InsertText( sd[frm.iDate] );
InsertText( st[frm.iTime] );
end;
end;
begin
init;
run;
end.