DateInterval is using Int32 when you add to DateTime

LR says that Xojo.Core.DateInterval and new DateInterval use Integer, then you go to the Integer docs and it says:

so I expect to be able to use an integer value of 2,147,483,648 for a DateInterval in a 64-bit app but I can’t, I get the wrong value/result.

Sorry if I posted this before, I was not able to find the thread but I guess I should have complained because my case was closed as not reproducible: <https://xojo.com/issue/56627> even when I provided the code.

I just want the docs updated to say they use Int32 and not Integer.

Edit: I remember now, I had a case before this one and the answer I received when closed that one:

I know I should not try to use DateInterval with 2 billion seconds or 2 billion nanoseconds, but the docs are saying that Xojo.Core.DateInterval and DateInterval use Integer and if it is not using Int64 in a 64-bit system, then there should be a note that DateInterval uses Int32, no?

[quote=493192:@Alberto DePoo]Edit: I remember now, I had a case before this one and the answer I received when closed that one:

You shouldn’t be trying to alter the time by adding 2 billion seconds.
[/quote]

The math/code should work as documented regardless of what they might think is good practice… That IMO is what it means to have robust code.

-Karen

Undocumented behavior is always a great way to end up scratching your head. Somehow your code doesn’t work, you suspect that you have made a mistake, you look at the language reference and it says your code is correct. You are now left scratching your head, 6 hours later after exhausting all possibility that you made a mistake you come to the conclusion the issue is not yours and you can’t help but get upset. You thought you had made a mistake but you were mistaken.

Is it possible that it is supposed to be 64 bit but its failing like this issue? https://forum.xojo.com/60632-returning-some-int64-s-from-methods-with-return-type-auto-gives

[quote=493192:@Alberto DePoo]LR says that Xojo.Core.DateInterval and new DateInterval use Integer, then you go to the Integer docs and it says:

so I expect to be able to use an integer value of 2,147,483,648 for a DateInterval in a 64-bit app but I can’t, I get the wrong value/result.

Sorry if I posted this before, I was not able to find the thread but I guess I should have complained because my case was closed as not reproducible: <https://xojo.com/issue/56627> even when I provided the code.

I just want the docs updated to say they use Int32 and not Integer.

Edit: I remember now, I had a case before this one and the answer I received when closed that one:

I know I should not try to use DateInterval with 2 billion seconds or 2 billion nanoseconds, but the docs are saying that Xojo.Core.DateInterval and DateInterval use Integer and if it is not using Int64 in a 64-bit system, then there should be a note that DateInterval uses Int32, no?[/quote]
Just out of curiosity… how much is it off?

Just the expected Int32 behavior when you try to use 2,147,483,648 you will really use -2,147,483,648 because Int32 just go as high as 2,147,483,647

Here I’m adding an Interval of 2,147,483,647 and 2,147,483,648 nanoseconds using Xojo.Core.Date and 2,147,483,647 and 2,147,483,648 seconds using DateTime. Because is a 64-bit application all dates are expected to be in the future:

Edit: if you try to add 4294967296 is the same as adding 0

DateInterval uses Int64 without problems to store the information, only when you add the DateInterval to a DateTime is when Int32 is used:

Var myinterval As New DateInterval(0, 0, 0, 0, 0, 2147580000) //2147580000 seconds
Var date1970 As New DateTime(0) //1969-12-31 18:00:00 //0 SecondsFrom1970
Var date1970_interval As DateTime = date1970 + myinterval //1901-12-14 17:31:44 
 //-2147387296 SecondsFrom1970
Var date2038 As New DateTime(myinterval.Seconds) //2038-01-20 00:00:00 //2147580000 SecondsFrom1970

Should I open another feedback case?

See the response above, do you want me to open a new feedback case?

I just saw today that Color.FromString has a 32bit limit problem too:
<https://xojo.com/issue/64167>
that’s why I looked for this.

1 Like

Instead of using a DateInterval for this, I suggest just using the DateTime Constructor which takes a double…

Sure