EncodeDate Rounding issue
Issue #65
resolved
Hello,
Encoding a data returns wrong value (=rounding issue).
procedure Test;
var
d, d2: TDate;
isE: Boolean;
begin
d := Date;
d2 := EncodeDate(YearOf(d),MonthOf(d),DAyOf(d));
isE := d=d2;
WriteLn(Format('Equal: %s, d: %d, d2: %d', [isE.ToString,d,d2]));
end;
Result:
Equal: False, d: 42557, d2: 42556.91666666667 [line #352]
Comments (5)
-
repo owner -
reporter It's in SmartMobileStudio v2.2
http://forums.smartmobilestudio.com/index.php?/topic/4125-encodedate-rounding-issue/
-
repo owner Time and Date are in UTC, I guess what you are seeing is that the TZ mode for EncodeDate is Local, so you end up with a delta of the timezone offset.
If so adding DateTimeZone.UTC as last parameter of EncodeDate should give you the same value
-
reporter Thanks. Thats it.
-
repo owner - changed status to resolved
- Log in to comment
Which language/platform is this test intended for?
AFAICT it does not compile in DWScript (different function names), and in Delphi it would not hit the DWScript date functions.