Author: Lou Adler
How to use RTTI to determine if a property is a TDateTime
Answer:
When it comes to RTTI, TDateTime and Double are not the same. That's what the extra
"type" keyword in TDateTime's declaration is for: to give it its own RTTI, distinct
from that of Double. Here is an example:
1 program Test;
2 3 uses4 TypInfo;
5 6 {$APPTYPE CONSOLE}7 {$M+}8 type9 TTest = class10 private11 FDateTime: TDateTime;
12 published13 property D: TDateTime read FDateTime write FDateTime;
14 end;
15 16 var17 T: TTest;
18 DateInfo: Pointer;
19 TestInfo: PPropInfo;
20 begin21 T := TTest.Create;
22 DateInfo := TypeInfo(TDateTime);
23 TestInfo := GetPropInfo(T, 'D');
24 writeln(DateInfo = TestInfo^.PropType^);
25 readln;
26 end.
It should print TRUE on the console.