Date.TotalSeconds is negative

According to the LR, Date.TotalSeconds should be positive for dates after 12:00AM, January 1, 1904. This doesn’t seem to be the case for me.

I made a check in my code to exclude some odd dates that somehow slipped into my database (Year 2), so I tested against total seconds, only allowing posts with positive totalseconds to be used. For some reason NOTHING slipped past that test. It turns out TotalSeconds is also negative for the current date.

As you can see from this screenshot from the debugger, something strange is going on here, as the date is both october 30th and october 13th in that Date.

Can anyone confirm this behavior?

OS X 10.8.4, Xojo 2013.R3

Are you storing total seconds in an intger or int32? IIRC it’s a double because when it was introduces the language did not support uint64 or int64.

I’m on 10.8.5 and 2013r2 my debugger test shows okay in a window with a push button. Is the date in your screen shot directly from the database?

Can’t confirm. Works on OS X 10.8.5 + Xojo 2013.3 ok.
30. Oktober 2013 is a “onsdag” not an “torsdag”.
13. Oktober 2013 DayOfYear = 286 not 287

Maybe a DisplayBug in debugger. Maybe ?

This is what I’m getting:

This is the code I used:

dim d as new date d.GMTOffset = 2 d.SQLDateTime = "2013-10-13 17:15:22"

It seems to vary, depending on the way you set it. In the example above, I used;


and that gave this weird result.


instead produces the correct result - so far.

I get the same results using both methods.

Are you using Sqlite?

Yes, it’s Sqlite, so it could be a bug in the sqlite implementation.

It’s not really a big deal for my app, as it’s just as easy testing on Year as totalSeconds. I just happened to use it that way, when I discovered this “issue”.
As far as I can tell, there are no problems with Date anywhere else.

I wonder how your code differs from mine. Here’s what I slapped together: Download

When I peek into the debugger the two different methods yield the same results.

Could it be that the regional settings of the computer could cause display problems? If i look at Joseph’s picture of his date program i see that the totalseconds is displayed as a large integer while if i run his example program i see the totalseconds displayed as a floating point number. To me it feels like inconsistent behaviour.

Lars also appears to be getting a large integer. If I output the value to a listbox using str I also get the floating point value.