Does Xojo have a way to parse a string value to see if it is a valid time string? The following should be considered valid:
3:40 PM
3:40:12 PM
15:40
15:40:12
I’ve tried using the ParseDateMBS which almost works but it requires seconds to be present and if I put 3:40:00 PM it validates it as 3:40:00 AM so not sure how to work around that.
var hour,minutes,seconds as integer
var datearray() as string
datearray = texttime.split(":")
hour = datearray(0).tointeger
minutes = datearray(1).tointeger
try
seconds = datearray(2).tointeger
exception
seconds = 0
end try
if texttime.indexof("PM") > 0 then hour = hour+12
var thedatetime as new datetime(2023,1,1,hour,minutes,seconds)
return thedatetime