Atozed Forums

Full Version: IdDateTimeStamp gives strange result
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I might have missed something, but tried a very simple code:

procedure TForm1.Button1Click(Sender: TObject);

and got the result:

9-7-19 12:06:56

i.e. the Year, the Month and the Day are all +1 compared to the real one. I tried other dates and always this offset.

Any idea?

I use Debian 9, Gnome 3.22.2, Lazarus 2.0.2., FPC 3.0.4, on 64 bit.
The SetFromTDateTime() method calls the Zero() method to initialize the TIdDateTimeStamp before adding the TDateTime.  However, Zero() sets the initial year and day values to 1, not 0.  Even the SetYear() and SetDay() methods force 0 to 1.  I do not know why.  I did not write TIdDateTimeStamp, I do not know the methodology behind it, but it was clearly intentional behavior, albeit it does seem wrong.

There is an existing ticket for this in Indy's issue tracker, I just haven't gotten around to fixing it yet:

#67: TIdDateTimeStamp.SetFromTDateTime is one year ahead