mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-05 10:18:22 +02:00

a) it's Delphi-incompatible b) when a tdatetime property is obtained via GetPropValue(), then it will be a varfloat rather than a vardate, and there full precision certainly is required (mantis #15296) - since DoVarCmpFloat() is now identical to DoVarCmpDate(), removed DoVarCmpFloat git-svn-id: trunk@14472 -
50 lines
1.1 KiB
ObjectPascal
50 lines
1.1 KiB
ObjectPascal
program TestProject;
|
|
|
|
{$mode objfpc}{$H+}
|
|
|
|
uses
|
|
SysUtils, TypInfo;
|
|
|
|
type
|
|
TTestObject = class(TObject)
|
|
private
|
|
FDate1: TDateTime;
|
|
FDate2: TDateTime;
|
|
published
|
|
property Date1: TDateTime read FDate1 write FDate1;
|
|
property Date2: TDateTime read FDate2 write FDate2;
|
|
end;
|
|
|
|
var
|
|
VarDate1: Variant;
|
|
VarDate2: Variant;
|
|
TestObject: TTestObject;
|
|
|
|
begin
|
|
TestObject := TTestObject.Create;
|
|
TestObject.Date1 := EncodeDate(1999, 02, 06) + EncodeTime(20, 0, 0, 0);
|
|
TestObject.Date2 := EncodeDate(1999, 02, 06) + EncodeTime(20, 0, 0, 1);
|
|
|
|
// works ok
|
|
//VarDate1 := TestObject.Date1;
|
|
//VarDate2 := TestObject.Date2;
|
|
|
|
// rounding occurs
|
|
// variants are interpreted as floats
|
|
// but this code works in delphi as expected (different when comparing)
|
|
// so don't know is this comparisson problem or values are rounded too much.
|
|
VarDate1 := GetPropValue(TestObject, 'Date1');
|
|
VarDate2 := GetPropValue(TestObject, 'Date2');
|
|
|
|
if VarDate1 = VarDate2 then
|
|
begin
|
|
WriteLn('Dates are equal.');
|
|
halt(1);
|
|
end
|
|
else
|
|
WriteLn('Dates are not equal.');
|
|
|
|
TestObject.Free;
|
|
end.
|
|
|