-
Notifications
You must be signed in to change notification settings - Fork 4
/
lpeval_wrappers_datetime.inc
126 lines (103 loc) · 4.64 KB
/
lpeval_wrappers_datetime.inc
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
{
Author: Niels A.D
Project: Lape (http://code.google.com/p/la-pe/)
License: GNU Lesser GPL (http://www.gnu.org/licenses/lgpl.html)
This include constains all the wrappers for DateTime related functions.
}
{%MainUnit lpeval.pas}
procedure _LapeEncodeDate(const Params: PParamArray; const Result: Pointer); {$IFDEF Lape_CDECL}cdecl;{$ENDIF}
begin
PDateTime(Result)^ := EncodeDate(PUInt16(Params^[0])^, PUInt16(Params^[1])^, PUInt16(Params^[2])^);
end;
procedure _LapeEncodeTime(const Params: PParamArray; const Result: Pointer); {$IFDEF Lape_CDECL}cdecl;{$ENDIF}
begin
PDateTime(Result)^ := EncodeTime(PUInt16(Params^[0])^, PUInt16(Params^[1])^, PUInt16(Params^[2])^, PUInt16(Params^[3])^);
end;
procedure _LapeDecodeDate(const Params: PParamArray); {$IFDEF Lape_CDECL}cdecl;{$ENDIF}
begin
DecodeDate(PDateTime(Params^[0])^, PUInt16(Params^[1])^, PUInt16(Params^[2])^, PUInt16(Params^[3])^);
end;
procedure _LapeDecodeDateFully(const Params: PParamArray; const Result: Pointer); {$IFDEF Lape_CDECL}cdecl;{$ENDIF}
begin
PBoolean(Result)^ := DecodeDateFully(PDateTime(Params^[0])^, PUInt16(Params^[1])^, PUInt16(Params^[2])^, PUInt16(Params^[3])^, PUInt16(Params^[4])^);
end;
procedure _LapeDecodeTime(const Params: PParamArray); {$IFDEF Lape_CDECL}cdecl;{$ENDIF}
begin
DecodeTime(PDateTime(Params^[0])^, PUInt16(Params^[1])^, PUInt16(Params^[2])^, PUInt16(Params^[3])^, PUInt16(Params^[4])^);
end;
procedure _LapeDateTimeToStr(const Params: PParamArray; const Result: Pointer); {$IFDEF Lape_CDECL}cdecl;{$ENDIF}
begin
PlpString(Result)^ := lpString(DateTimeToStr(PDateTime(Params^[0])^));
end;
procedure _LapeDateToStr(const Params: PParamArray; const Result: Pointer); {$IFDEF Lape_CDECL}cdecl;{$ENDIF}
begin
PlpString(Result)^ := lpString(DateToStr(PDateTime(Params^[0])^));
end;
procedure _LapeTimeToStr(const Params: PParamArray; const Result: Pointer); {$IFDEF Lape_CDECL}cdecl;{$ENDIF}
begin
PlpString(Result)^ := lpString(TimeToStr(PDateTime(Params^[0])^));
end;
procedure _LapeDate(const Params: PParamArray; const Result: Pointer); {$IFDEF Lape_CDECL}cdecl;{$ENDIF}
begin
PDateTime(Result)^ := Date();
end;
procedure _LapeTime(const Params: PParamArray; const Result: Pointer); {$IFDEF Lape_CDECL}cdecl;{$ENDIF}
begin
PDateTime(Result)^ := Time();
end;
procedure _LapeNow(const Params: PParamArray; const Result: Pointer); {$IFDEF Lape_CDECL}cdecl;{$ENDIF}
begin
PDateTime(Result)^ := Now();
end;
procedure _LapeGetTickCount(const Params: PParamArray; const Result: Pointer); {$IFDEF Lape_CDECL}cdecl;{$ENDIF}
begin
{$IF DECLARED(GetTickCount64)}
PUInt64(Result)^ := GetTickCount64();
{$ELSE}
{$IF DECLARED(GetTickCount)}
PUInt64(Result)^ := GetTickCount();
{$ELSE}
PUInt64(Result)^ := Trunc(Now() * 24 * 60 * 60 * 1000);
{$IFEND}
{$IFEND}
end;
procedure _LapeSleep(const Params: PParamArray); {$IFDEF Lape_CDECL}cdecl;{$ENDIF}
begin
Sleep(PUInt32(Params^[0])^);
end;
procedure _LapeReplaceTime(const Params: PParamArray); {$IFDEF Lape_CDECL}cdecl;{$ENDIF}
begin
ReplaceTime(PDateTime(Params^[0])^, PDateTime(Params^[1])^);
end;
procedure _LapeReplaceDate(const Params: PParamArray); {$IFDEF Lape_CDECL}cdecl;{$ENDIF}
begin
ReplaceDate(PDateTime(Params^[0])^, PDateTime(Params^[1])^);
end;
procedure _LapeFormatDateTime(const Params: PParamArray; const Result: Pointer); {$IFDEF Lape_CDECL}cdecl;{$ENDIF}
begin
PlpString(Result)^ := lpString(FormatDateTime(string(PlpString(Params^[0])^), PDateTime(Params^[1])^));
end;
procedure _LapeStrToDate(const Params: PParamArray; const Result: Pointer); {$IFDEF Lape_CDECL}cdecl;{$ENDIF}
begin
PDateTime(Result)^ := StrToDate(string(PlpString(Params^[0])^));
end;
procedure _LapeStrToDateDef(const Params: PParamArray; const Result: Pointer); {$IFDEF Lape_CDECL}cdecl;{$ENDIF}
begin
PDateTime(Result)^ := StrToDateDef(string(PlpString(Params^[0])^), PDateTime(Params^[1])^);
end;
procedure _LapeStrToTime(const Params: PParamArray; const Result: Pointer); {$IFDEF Lape_CDECL}cdecl;{$ENDIF}
begin
PDateTime(Result)^ := StrToTime(string(PlpString(Params^[0])^));
end;
procedure _LapeStrToTimeDef(const Params: PParamArray; const Result: Pointer); {$IFDEF Lape_CDECL}cdecl;{$ENDIF}
begin
PDateTime(Result)^ := StrToTimeDef(string(PlpString(Params^[0])^), PDateTime(Params^[1])^);
end;
procedure _LapeStrToDateTime(const Params: PParamArray; const Result: Pointer); {$IFDEF Lape_CDECL}cdecl;{$ENDIF}
begin
PDateTime(Result)^ := StrToDateTime(string(PlpString(Params^[0])^));
end;
procedure _LapeStrToDateTimeDef(const Params: PParamArray; const Result: Pointer); {$IFDEF Lape_CDECL}cdecl;{$ENDIF}
begin
PDateTime(Result)^ := StrToDateTimeDef(string(PlpString(Params^[0])^), PDateTime(Params^[1])^);
end;