-
Notifications
You must be signed in to change notification settings - Fork 4
/
lpeval_import_datetime.inc
59 lines (49 loc) · 3.04 KB
/
lpeval_import_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
{
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 lpcompiler.pas}
addGlobalVar(HoursPerDay, 'HoursPerDay').isConstant := True;
addGlobalVar(MinsPerHour, 'MinsPerHour').isConstant := True;
addGlobalVar(SecsPerMin, 'SecsPerMin').isConstant := True;
addGlobalVar(MSecsPerSec, 'MSecsPerSec').isConstant := True;
addGlobalVar(MinsPerDay, 'MinsPerDay').isConstant := True;
addGlobalVar(SecsPerDay, 'SecsPerDay').isConstant := True;
addGlobalVar(MSecsPerDay, 'MSecsPerDay').isConstant := True;
addGlobalVar(DateDelta, 'DateDelta').isConstant := True;
addGlobalType(getBaseType(ltDouble).createCopy(True), 'TDateTime', False);
addGlobalFunc('function EncodeDate(Year, Month, Day: UInt16): TDateTime;', @_LapeEncodeDate);
addGlobalFunc('function EncodeTime(Hour, Min, Sec, MSec: UInt16): TDateTime;', @_LapeEncodeTime);
addGlobalFunc('procedure DecodeDate(DateTime: TDateTime; var Year, Month, Day: UInt16);', @_LapeDecodeDate);
addGlobalFunc('function DecodeDateFully(DateTime: TDateTime; var Year, Month, Day, DOW: UInt16): Boolean;', @_LapeDecodeDateFully);
addGlobalFunc('procedure DecodeTime(DateTime: TDateTime; var Hour, Min, Sec, MSec: UInt16);', @_LapeDecodeTime);
addGlobalFunc('function DateTimeToStr(const DateTime: TDateTime): string;', @_LapeDateTimeToStr);
addGlobalFunc('function DateToStr(const DateTime: TDateTime): string;', @_LapeDateToStr);
addGlobalFunc('function TimeToStr(const DateTime: TDateTime): string;', @_LapeTimeToStr);
TLapeType_OverloadedMethod(Globals['ToString'].VarType).addMethod(
TLapeType_Method(addManagedType(
TLapeType_Method.Create(
Self,
[getGlobalType('TDateTime')],
[lptConstRef],
[TLapeGlobalVar(nil)],
getBaseType(ltString)
)
)).NewGlobalVar(@_LapeDateTimeToStr)
);
addGlobalFunc('function Date: TDateTime;', @_LapeDate);
addGlobalFunc('function Time: TDateTime;', @_LapeTime);
addGlobalFunc('function Now: TDateTime;', @_LapeNow);
addGlobalFunc('function GetTickCount: UInt64;', @_LapeGetTickCount);
addGlobalFunc('procedure Sleep(MilliSeconds: UInt32);', @_LapeSleep);
addGlobalFunc('procedure ReplaceTime(var DateTime: TDateTime; NewTime: TDateTime);', @_LapeReplaceTime);
addGlobalFunc('procedure ReplaceDate(var DateTime: TDateTime; NewDate: TDateTime);', @_LapeReplaceDate);
addGlobalFunc('function FormatDateTime(Format: string; DateTime: TDateTime): string;', @_LapeFormatDateTime);
addGlobalFunc('function StrToDate(s: string): TDateTime;', @_LapeStrToDate);
addGlobalFunc('function StrToDateDef(s: string; Default: TDateTime): TDateTime;', @_LapeStrToDateDef);
addGlobalFunc('function StrToTime(s: string): TDateTime;', @_LapeStrToTime);
addGlobalFunc('function StrToTimeDef(s: string; Default: TDateTime): TDateTime;', @_LapeStrToTimeDef);
addGlobalFunc('function StrToDateTime(s: string): TDateTime;', @_LapeStrToDateTime);
addGlobalFunc('function StrToDateTimeDef(s: string; Default: TDateTime): TDateTime;', @_LapeStrToDateTimeDef);