Android Question Problem with DateUtils

RB Smissaert

Well-Known Member
Licensed User
Using the latest DateUtils library, 1.05.

Running this code:

B4X:
Dim lDate As Long
lDate = DateUtils.SetDate(1970,1,1)
Log(lDate)

I expect this to produce 0, but instead I get 3600000

Any idea what I might be doing wrong?

RBS
 

RB Smissaert

Well-Known Member
Licensed User
Yes, a similar issue is explained in this tutorial:


Tip: if you need to make "corrections" to the time zone effects then you are doing something wrong.

OK, thanks. I wrongly presumed that DST wouldn't affect DateUtils.SetDate(1970,1,1).

I solved this now with a Public variable (set once in Sub Service_Create):

B4X:
General.lTicksOff = DateUtils.SetDate(1970, 1, 1)

Now this function works fine:

B4X:
Public Sub Ticks2ExcelDate(lTicks As Long) As Long
 Return 25569 + ((lTicks - lTicksOff) / 86400000)
End Sub

RBS
 
Upvote 0
Top