-
Notifications
You must be signed in to change notification settings - Fork 0
/
SETIME.PAS
81 lines (77 loc) · 1.63 KB
/
SETIME.PAS
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
{ @author: Sylvain Maltais ([email protected])
@created: 2022
@website(https://www.gladir.com/os9-0)
@abstract(Target: Turbo Pascal, Free Pascal)
}
Program SETIME;
Uses DOS;
Var
Pos:(PMonth,PDay,PYear,PHour,PMin,PSec);
Year,Month,Day,DayOfMonth,Hour,Minute,Second,CentSec,Err:Word;
I:Byte;
S,T:String;
BEGIN
If(ParamStr(1)='/?')or(ParamStr(1)='--help')or(ParamStr(1)='-h')or
(ParamStr(1)='/h')or(ParamStr(1)='/H')Then Begin
WriteLn('SETIME : Cette commande permet de fixer l''horloge du systeme d''exploitation.');
WriteLn;
WriteLn('Syntaxe : SETIME aa/MM/dd hh:mm[:ss]');
End
Else
If ParamStr(1)<>''Then Begin
T:='';
Pos:=PYear;
S:=ParamStr(1);
For I:=1 to Length(S)do Begin
If S[I]<>'/'Then T:=T+S[I];
If S[I]='/'Then Begin
If Pos=PYear Then Begin
Val(T,Year,Err);
Pos:=PMonth;
End
Else
If Pos=PMonth Then Begin
Val(T,Month,Err);
Pos:=PDay;
End
Else
Val(T,Day,Err);
T:='';
End;
End;
If T<>''Then Val(T,Day,Err);
SetDate(Year,Month,Day);
S:=ParamStr(2);
If S<>''Then Begin
T:='';
Hour:=0;
Minute:=0;
Second:=0;
Pos:=PHour;
For I:=1 to Length(S)do Begin
If S[I]<>':'Then T:=T+S[I];
If S[I]=':'Then Begin
If Pos=PHour Then Begin
Val(T,Hour,Err);
Pos:=PMin;
End
Else
If Pos=PMin Then Begin
Val(T,Minute,Err);
Pos:=PSec;
End
Else
Val(T,Second,Err);
T:='';
End;
End;
If T<>''Then Begin
If(Pos=PMin)Then Val(T,Minute,Err)
Else Val(T,Second,Err);
End;
SetTime(Hour,Minute,Second,0);
End;
End
Else
WriteLn('Heure attendu');
END.