Atozed Forums
IdDateTimeStamp gives strange result - Printable Version

+- Atozed Forums (
+-- Forum: Indy (
+--- Forum: Indy General Discussion (
+--- Thread: IdDateTimeStamp gives strange result (/thread-1125.html)

IdDateTimeStamp gives strange result - jollytall - 07-09-2019

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.

RE: IdDateTimeStamp gives strange result - rlebeau - 07-09-2019

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