iOS Question Is there a equivalent for "ParseTime" in the iOS?

niveasoft

Member
Licensed User
Hello
I want to sort time from 6 in the morning to the 22 on the night as valid time.
Everything dont match should return false.
In the Android this was a piece of cake:
B4X:
Sub check_night_silent_conditions()As Boolean
       
    Dim under As Long
    Dim above As Long
    Dim timenow As Long
    DateTime.TimeFormat = "HH:mm:ss"
    under = DateTime.TimeParse("06:00:00")
    above = DateTime.TimeParse("23:59:59")
   
    timenow = DateTime.now
   
    If under < timenow Then 'below 6 in the morning
        hd.ToastMessageShow("Sterownik nie zezwoli","CISZA NOCNA!")
        Return False
    Else
        If above > timenow Then 'above 22 of the night
            hd.ToastMessageShow("Sterownik nie zezwoli","CISZA NOCNA!")
            Return False
        End If
    End If
   
    Return True
End Sub

Is there a equivalent for iOS like in the post theme mentioned?

Thanks in advance and sorry if I search awkwardly :D
 

niveasoft

Member
Licensed User
Okay. This is tested and it work fine.
B4X:
Sub check_night_silent_conditions()As Boolean
           
    DateTime.TimeFormat = "HH:mm:ss"
    Dim timenow As Long = DateTime.Now
    Dim datenow As String = DateTime.Date(timenow)
    Dim under As Long = DateTime.DateTimeParse(datenow,"06:00:00")
    Dim above As Long = DateTime.DateTimeParse(datenow,"21:59:59")

    If timenow < under Then
    Return False
    Else If timenow > above Then
    Return False
    End If
  Return True 
End Sub
 
Upvote 0
Top