In another bug report I had mentioned there is no way of returning to the default/hardware timezone offset in the DateTime object. In the mean time I added a Global variable to hold the offset when the activity starts so I can set it to 0 and save GMT time text then return it to the default when done. I thought it was working fine until after saving I tried to set the time again.
I have a Button with the selected time as its text. when you click the button it calls:
What is confusing is I use DateTime to populate the ticks and use it again to get the text to set the control to yet they return 2 different results. Lets say the time on the device is 12:34. When I click the button the Time Dialog is shown with 12:34. When I click Ok in the time dialog the text I get back from DateTime.Time(td.TimeTicks) is 13:34.
DateTime.GetTimeZoneOffsetAt(DateTime.Now) and the TimezoneOffset in the DateTime Object both report -5 for my timezone. During the Fall/Winter it is -6, so that it goes up an hour is actually opposite of a DST issue. I've also ruled out the shifting to 0 and back being an issue by setting the offset with SetTimeZone right after capturing the current value when the activity starts. So, I get the value of -5 and set it back to -5 and now my text from the Time Dialog returns off by an hour, so something additional is happening to the DateTime object when you set the offset. It is almost like it thinks I'm setting my timezone to Eastern instead of Central.
The problem seems to be similar to the other reported in that the object is trying to set Timezone by Offset which cannot work. So, I'm right back to still no way of restoring the default timezone offset. The Time Dialog appears to use its own DateTime object too which confuses the matter even more since it always shows the correct time.
I have a Button with the selected time as its text. when you click the button it calls:
B4X:
Sub Get_Time
td.TimeTicks = DateTime.Now
td.Is24Hours = True
If td.Show("Please Select Incident Time", "Incident Time", "Ok", "Cancel", "", Null) = DialogResponse.POSITIVE Then
VM.SetText("IncidentTime", DateTime.Time(td.TimeTicks))
End If
End Sub
What is confusing is I use DateTime to populate the ticks and use it again to get the text to set the control to yet they return 2 different results. Lets say the time on the device is 12:34. When I click the button the Time Dialog is shown with 12:34. When I click Ok in the time dialog the text I get back from DateTime.Time(td.TimeTicks) is 13:34.
DateTime.GetTimeZoneOffsetAt(DateTime.Now) and the TimezoneOffset in the DateTime Object both report -5 for my timezone. During the Fall/Winter it is -6, so that it goes up an hour is actually opposite of a DST issue. I've also ruled out the shifting to 0 and back being an issue by setting the offset with SetTimeZone right after capturing the current value when the activity starts. So, I get the value of -5 and set it back to -5 and now my text from the Time Dialog returns off by an hour, so something additional is happening to the DateTime object when you set the offset. It is almost like it thinks I'm setting my timezone to Eastern instead of Central.
The problem seems to be similar to the other reported in that the object is trying to set Timezone by Offset which cannot work. So, I'm right back to still no way of restoring the default timezone offset. The Time Dialog appears to use its own DateTime object too which confuses the matter even more since it always shows the correct time.