[fpc-devel] Behavior of conversion between vardate variants and string in fpc and delphi
LacaK
lacak at zoznam.sk
Mon Apr 4 09:34:03 CEST 2011
> So, what should be done?
>
> 1) Be totally compatible with Delphi: convert date to string with
> hardcoded format and raise exception when doing the conversion back?
> 2) Use the hardcoded format used to convert from vardate variant to
> string and vice versa?
> 3) Use shortdateformat to convert from vardate variant to string and
> vice versa?
Point 3 sounds to me as best and logical.
This code in DelphiXE:
ShortDateFormat := 'dd#mm#yyyy'; // the problem occurs regardless of
the format option
DateSeparator:='#';
V := '20#04#2011';
v1:=varAsType(V, varDate);
D:=v1;
Writeln('Date: ' + DateToStr(D));
Outputs:
Date: 20#04#2011
So it seems, that DelphiXe also uses ShortDateFormat, DateSeparator
Laco.
More information about the fpc-devel
mailing list