Created
October 3, 2021 14:22
-
-
Save FrBrGeorge/d6c84f8ffa50b178a85d610d5a23d23f to your computer and use it in GitHub Desktop.
check if time is in hh:mm:ss format
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
procedure Check(d: string; var res: boolean; var hms: vec); | |
var | |
i, r: integer; | |
begin | |
res := length(d) = 8; | |
if not res then exit; | |
res := (d[3] = ':') AND (d[6] = ':'); | |
if not res then exit; | |
for i:=1 to 3 do | |
begin | |
val(copy(d, 1+(i-1)*3, 2), hms[i], r); | |
res := r = 0; | |
if not res then exit; | |
end; | |
res := (hms[1] <= 24) AND (hms[2] <= 60) and (hms[3] <= 60); | |
end; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment