Bug? Datetime Bug (b4j & b4a) FIXED!

ilan

Expert
Licensed User
Longtime User
i found a bug in b4j & b4a.

it seems like the Parsing from string to long is wrong. the weird thing is that it will work in some case and in some not.

this code will return a wrong number of minutes:

B4X:
    Dim d1, t1, d2, t2 As String
    d1 = "23/03/2017"
    t1 = "18:00:00"
    d2 = "24/03/2017"
    t2 = "17:00:00"
   
    DateTime.DateFormat = "dd/MM/yyyy"
    DateTime.TimeFormat = "HH:mm:ss"
   
    Dim start, endtime As Long
   
    start = DateTime.DateTimeParse(d1,t1)
    endtime = DateTime.DateTimeParse(d2,t2)
   
    Log((endtime - start) / DateTime.TicksPerMinute)

log = 1320 but it should be 1380 (23 hours)
 

barx

Well-Known Member
Licensed User
Longtime User
Have you tried logging start and endtime back as strings to see where it is going wrong?
 

ilan

Expert
Licensed User
Longtime User
Have you tried logging start and endtime back as strings to see where it is going wrong?

found the issue :oops:

today in israel we change our clock to summer time (+1h) and this is the reason why it shows me 1 hour less so setting the timezone to 0 will solve the problem

B4X:
DateTime.SetTimeZone(0)
 
Last edited:

barx

Well-Known Member
Licensed User
Longtime User
Just to let you know it returns 1380 here.

B4J 4.70
 

barx

Well-Known Member
Licensed User
Longtime User
if the


found the issue :oops:

today in israel we change our clock to summer time (+1h) and this is the reason why it shows me 1 hour less so setting the timezone to 0 will solve the problem

B4X:
DateTime.SetTimeZone(0)


LOL
 
Top