Hi All.
I have struck a problem that I just can figure out.
Here is what I am doing:
Dim dNewTime As Long
dNewTime =(DateTime.TimeParse("15:43:15") Mod DateTime.TicksPerDay)
when I go:
sTime = "15:43:15"
Log("TIME PARSED:" & sTime & " Date and Time:" & DateTime.Date(dNewTime) & " " & DateTime.Time(dNewTime))
I get this output:
TIME PARSED:15:43:15 Date and Time:01/43/1970 15:43:15
Notice the date? if you now take a look at the following times done the same way as the above:
TIME PARSED:01:12:30 Date and Time:01/12/1970 01:12:30
TIME PARSED:01:21:28 Date and Time:01/21/1970 01:21:28
TIME PARSED:01:27:20 Date and Time:01/27/1970 01:27:20
TIME PARSED:01:31:28 Date and Time:01/31/1970 01:31:28
TIME PARSED:01:59:57 Date and Time:01/59/1970 01:59:57
TIME PARSED:02:19:22 Date and Time:01/19/1970 02:19:22
TIME PARSED:02:28:42 Date and Time:01/28/1970 02:28:42
TIME PARSED:02:45:47 Date and Time:01/45/1970 02:45:47
What you will notice is the month part (or day part) is the same value as the seconds ! This is NOT very helpful when I add the time to a date as the output below:
Date and Time:19/16/2011 01:16:30
BUT....it doesnt end there. if I go
Dim dNewTime As Long
dNewTime =DateTime.DateParse("19/04/2011")
Log(" Date and Time:" & DateTime.Date(dNewTime) & " " & DateTime.Time(dNewTime))
I get
Date and Time:19/04/2011 00:04:00
Notice the Mins part of the time is the same as the month value.
SO.....is this a bug, or (as usual) I have done something wrong?
Dim dNewTime As Long
dNewTime =(DateTime.TimeParse("15:43:15") Mod DateTime.TicksPerDay)
sTime = "15:43:15"
Log("TIME PARSED:" & sTime & " Date and Time:" & DateTime.Date(dNewTime) & " " & DateTime.Time(dNewTime))
Gives on both my ZTE Blade and my Motorola Xoom
B4X:
LogCat connected to: P729B
Debug connected: true
** Activity (main) Create, isFirst = true **
TIME PARSED:15:43:15 Date and Time:01/01/1970 15:43:15
** Activity (main) Resume **
You posted the fragment of code where you ASSUMED the problem to be but didn't post the fragment that was the ACTUAL problem. This is very common and is why it is usually better to post a small but complete project that demonstrates the "error" rather than posting partial copies of the code that might not actually contain the problem.