Android Question AnotherDatePicker - dates before 1970

LucaMs

Expert
Licensed User
It seems to me that AnotherDatePicker allows you to select a date before 1970 but in this case the DateChanged event does not fire.

Am I wrong?
 

LucaMs

Expert
Licensed User
original code
B4X:
Private Sub DateField_TextChanged (Old As String, New As String)
    Dim ticks As Long = GetCurrentDateFromTextField (New)
    If ticks > 0 Then
but for a date: 02/21/1968 ticks are -58755600000, so the event does not fire.
 

LucaMs

Expert
Licensed User
I have not watched the update yet but...

It seems enough to change that line:...
I think it is not enough, because:

B4X:
Private Sub GetCurrentDateFromTextField (DateString As String) As Long
    Try
        Dim ticks As Long = DateTime.DateParse(DateString)
        If DateTime.GetYear(ticks) >= minYear And DateTime.GetYear(ticks) <= maxYear Then
            Return ticks
        End If
    Catch
        'invalid date
    End Try 'ignore
    Return 0
End Sub
And zero is a valid number of ticks for a date (1/1/1970).

Maybe GetCurrentDateFromTextField should return an Object and so you can return a different value (Null) for an invalid date.
 
Top