I am trying to keep track of countdown to future events.
Basically I substract time ticks (in long).
I get the correct countdowns, but when I try to display that in string (hour, minute, seconds) I get an anwser biased by two hours.
Here is the code:
And log file
For example the first event gives correctly 1800000 ticks, but this is displayed as 2:30:00 instead of 30 minutes.
What did I wrong?
Basically I substract time ticks (in long).
I get the correct countdowns, but when I try to display that in string (hour, minute, seconds) I get an anwser biased by two hours.
Here is the code:
B4X:
Sub UpdateCountDowns(rightnow As Long)
Dim i As Int
DateTime.TimeFormat = "dd/MM/yyy HH:mm:ss"
For i = 0 To 2
Log("Event " & i & " at: " & Evt(i).EventTimeA & ", " & DateTime.Time(Evt(i).EventTimeA))
Log("Now is: " & rightnow & ", " & DateTime.Time(rightnow))
Evt(i).CountDownA = Evt(i).EventTimeA - rightnow
Log("set count down to: " & Evt(i).CountDownA & ", " & DateTime.Time(Evt(i).CountDownA))
Next
Log ("GetTimeZoneOffsetAt: " & DateTime.GetTimeZoneOffsetAt(rightnow))
Log ("TimeZoneOffset: " & DateTime.TimeZoneOffset)
End Sub
And log file
B4X:
Event 0 at: 1335919936936, 02/05/2012 03:52:16
Now is: 1335918136936, 02/05/2012 03:22:16
set count down to: 1800000, 01/01/1970 02:30:00
Event 1 at: 1335924028482, 02/05/2012 05:00:28
Now is: 1335918136936, 02/05/2012 03:22:16
set count down to: 5891546, 01/01/1970 03:38:11
Event 2 at: 1335940578412, 02/05/2012 09:36:18
Now is: 1335918136936, 02/05/2012 03:22:16
set count down to: 22441476, 01/01/1970 08:14:01
Event 3 at: 1335940897920, 02/05/2012 09:41:37
Now is: 1335918136936, 02/05/2012 03:22:16
set count down to: 22760984, 01/01/1970 08:19:20
Event 4 at: 1335953797749, 02/05/2012 13:16:37
Now is: 1335918136936, 02/05/2012 03:22:16
set count down to: 35660813, 01/01/1970 11:54:20
Event 5 at: 1335968292327, 02/05/2012 17:18:12
Now is: 1335918136936, 02/05/2012 03:22:16
set count down to: 50155391, 01/01/1970 15:55:55
Event 6 at: 1335976269580, 02/05/2012 19:31:09
Now is: 1335918136936, 02/05/2012 03:22:16
set count down to: 58132644, 01/01/1970 18:08:52
Event 7 at: 1335975619889, 02/05/2012 19:20:19
Now is: 1335918136936, 02/05/2012 03:22:16
set count down to: 57482953, 01/01/1970 17:58:02
Event 8 at: 1335982819889, 02/05/2012 21:20:19
Now is: 1335918136936, 02/05/2012 03:22:16
set count down to: 64682953, 01/01/1970 19:58:02
GetTimeZoneOffsetAt: 3
TimeZoneOffset: 3
For example the first event gives correctly 1800000 ticks, but this is displayed as 2:30:00 instead of 30 minutes.
What did I wrong?