Delphi的又一小缺陷: TDate赋值给Variant得到varDouble而不是varDate
2021-06-12 03:05
标签:var delphi for win 7 assert from rda type click Delphi的又一小缺陷: TDate赋值给Variant得到varDouble而不是varDate 标签:var delphi for win 7 assert from rda type click 原文地址:https://www.cnblogs.com/kinglandsoft/p/10536333.html//Delphi 10.3.1 32bit, Win 7 32bit
procedure TForm1.btnTimeToVariantClick(Sender: TObject);
var
d:TDate;
t:TTime;
v:Variant;
begin
d := Date();
t := Time();
v := d;
Assert( VarType(v)=varDouble ); //通过
v := Variant(d);
Assert( VarType(v)=varDouble ); //通过
v := VarFromDateTime(d);
Assert( VarType(v)=varDate ); //通过
v := t;
Assert( VarType(v)=varDouble ); //通过
v := VarFromDateTime(t);;
Assert( VarType(v)=varDate ); //通过
end;
文章标题:Delphi的又一小缺陷: TDate赋值给Variant得到varDouble而不是varDate
文章链接:http://soscw.com/index.php/essay/93793.html