In our previous episode, Bee Jay said: > Hi all, > > Try the following code snippet: > > uses > DateUtils; > var > a,b: TDateTime; > i: integer; > begin > a := EncodeDateTime(2010, 1, 1, 0, 0, 0, 0); > for i := 0 to 9 do > begin > b := EncodeDateTime(2010, 1, 1, 0, 0, i, 0); > Writeln(SecondsBetween(a,b):3); > end; > end; > > I think the result isn't correct. It also affects other > <time_fraction>Between functions e.g. SecondsBetween, MinutesBetween, > etc. > > But if I changed the milisecond part of a or b or both to anything but 0 > then the result is correct. Is this a bug? Or did I miss something?
IIRC this is normal and delphi compatible and due to TDatetime being a floating point type. *between does a trunc, and "time" is a floating point values, so values might be rounded here and there. Sometimes the rounding means that e.g. date+1second is rounded to a bit more than date + 1second. Then later secondsbetween sees no whole second between and this results in this behaviour. _______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal