DateTime TimeFormat problem

klaus

Expert
Licensed User
Longtime User
Hi Erel.
There seems to be an error in the DateTime.TimeFormat function.
With a given time in a given TimeFormat changing the time format and displaying it changes the time by one hour in certain time zones and is OK in others.
The code below shows the problem.
B4X:
Sub Activity_Resume
    Dim Time1, Time2, TimeFormat As String
    Dim TimeTicks As Long
    
    Time1 = "10:15"
    TimeFormat = DateTime.TimeFormat
    DateTime.TimeFormat = "HH:mm"
    TimeTicks = DateTime.TimeParse(Time1)
    DateTime.TimeFormat = TimeFormat
    Time2 = DateTime.Time(TimeTicks)
    Label1.Text = Time1
    Label2.Text = Time2
    Log(Time1)
    Log(Time2)
End Sub
Three examples:
With Central Euroean Time (Brussels) it's OK
With Greenwich time one hour difference
With Estern Time (New York) it's OK

Best regards.
 

Attachments

  • DateTime.zip
    6.8 KB · Views: 422

Harris

Expert
Licensed User
Longtime User
Date/Time and TimeZones are an issue in any language. We use Borland C++ and experience many of the same problems.

My colleges and I have proposed to use TimeZone(0) Greenwich to store Date/Time and and then use the local offset to report the current (recorded) time ( ie. -8 Pacific). DST crossover is always been an issue.

Could this strategy possibly possibly reduce date/time calculation problems?

Thanks
 
Top