Bug in evaluate

By chance, I found a bug in using @Adjust in a LS Evaluate statement.

Try running this agent. You’ll see that no day is added for the first date. Works fine for the other, or any other date I’ve tried. What’s so special about the 26th of October 2003?

This is quite worrying and makes me distrust using Evaluate anywhere.

Lotus, can you explain this???

Sub Initialize

Dim session As New notesSession

Dim DummyDoc As NotesDocument

Set db = session.currentDatabase

Set DummyDoc= db.CreateDocument



DummyDoc.DateArrived1 = Datevalue("26/10/2003")

DummyDoc.DateTemp1 = Evaluate({@Date(@Adjust(DateArrived1; 0;0;1;0;0;0))}, DummyDoc)	

DummyDoc.DateArrived2 = Datevalue("26/11/2003")

DummyDoc.DateTemp2 = Evaluate({@Date(@Adjust(DateArrived2; 0;0;1;0;0;0))}, DummyDoc)

End Sub

Subject: Bug in evaluate

Instead of invoking Evaluate why not use the LS version?

Set thisDate = New NotesDateTime(“26/10/2003”)

Call thisDate.AdjustDay(1)

This will eliminate the use of the Evaluate statement which I have found to be not reliable all of the time.

Hope this helped.

Subject: Has nothing to do w/ a bug in Evaluate. What is really happening is that you…

are running into a Daylight Savings time issue. If you try the same thing and put a time value in such as “26/10/2003 08:00 AM”, you will find that it works as expected.

Subject: Bug in evaluate

It is very simple: 26th of October 2003 had 25 hours :-).

It is a daylight savings time issue:

  • October 26 in 2003 was the DST switch day (ie: one extra hour added between 3:00/2:00).

  • You’re initializing your date as 26/10/2003 0:00.

  • You’re adding 24 hours, which makes the end result for that particular day 26/10/2003 23:00.

This is not an issue with evaluate in LS, but how @Adjust works in formula language.

One way to avoid this is to not use 0:00 as a time but e.g. 8:00. This way you won’t notice.

cheers,

Bram

Subject: RE: Bug in evaluate

Thanks guys, good thinking! I suppose I can also fix it by putting @Date around it. Because this does work:StartDate := @Date(2003; 10; 26; 0; 0; 0);

@Adjust(@Date(StartDate); 0;0;1;0;0;0)

You’d think that if LS can detect daylight savings, formulas could…