Delphi的又一小缺陷: TDate赋值给Variant得到varDouble而不是varDate

2021-06-12 03:05

阅读:462

标签:var   delphi   for   win 7   assert   from   rda   type   click   

//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

标签:var   delphi   for   win 7   assert   from   rda   type   click   

原文地址:https://www.cnblogs.com/kinglandsoft/p/10536333.html


评论


亲,登录后才可以留言!