I using this code, Because Board has a problem for records size capacity of epprom.
Sample
17:45:36 =8byte
174536 =6byte
mycode = 2byte (uint)
if you select "withsecond" options;
I must used each 2 second = 1tick
finally your seconds must be returns 2 and x2
Sample second: 31 >> return second 30
have nice weekend.
Source Code:
Sample
B4X:
Log("17:45:36 False >>",DateTime.TimeToUint(17,45,36,False)) '>>> 1065
Log("1065 // 17:45:36 False>>",DateTime.UintToTime(1065,False))' >> 174500
Log("17:45:36 True >>",DateTime.TimeToUint(17,45,36,True)) '>>>31968
Log("31968//17:45:36 True >>",DateTime.UintToTime(31968,True))'>>>174536
17:45:36 =8byte
174536 =6byte
mycode = 2byte (uint)
if you select "withsecond" options;
I must used each 2 second = 1tick
finally your seconds must be returns 2 and x2
Sample second: 31 >> return second 30
have nice weekend.
Source Code:
B4X:
Public Sub TimeToUint(HH As UInt,MM As UInt,SS As UInt,AddSec As Boolean) As UInt
If AddSec Then
Dim s As UInt
s=Floor(SS/2)
Return HH*1800+MM*30+s
Else
If HH>23 Then Return MM Else Return HH*60+MM
End If
End Sub
Public Sub UintToTime(Sayi As UInt,withsecond As Boolean) As String
Dim HH,MM,SS As UInt
If withsecond Then
HH=Floor(Sayi/1800)
MM=Floor((Sayi-HH*1800)/30)
SS=(Sayi-(HH*1800+MM*30))*2
Else
HH=Floor(Sayi/60)
MM=Sayi Mod 60
SS=0
End If
Return StdTimeToString(HH,MM,SS,withsecond)
End Sub
Public Sub StdSaatToString(HH As UInt,MM As UInt,SS As UInt,Addsec As Boolean) As String
Dim s As String
s=""
If HH<10 Then
s=JoinStrings(Array As String("0", HH))
Else
s=JoinStrings(Array As String(s, HH))
End If
If MM<10 Then
s=JoinStrings(Array As String(s,JoinStrings(Array As String("0", MM))))
Else
s=JoinStrings(Array As String(s, MM))
End If
If Addsec Then
If SS<10 Then
s=JoinStrings(Array As String(s,JoinStrings(Array As String("0", SS))))
Else if SS=0 Then
s=JoinStrings(Array As String(s, "00"))
Else
s=JoinStrings(Array As String(s, SS))
End If
End If
Return s
End Sub
Last edited: