Determines whether a specified time is valid
TimeValid( <cTime> ) --> lValid
<cTime> Designates a character string that contains the time to test.
TimeValid() RETURNs .T. when <cTime> is a valid time; or .F. when <cTime> is an invalid time.
With input that requires time manipulation, writing your own UDF to check time inputs was unavoidable up to now. TimeValid() permits Complete checking of a time designation. You can use this FUNCTION effectively with a VALID clause within a READ mask.
Note the format for time designations. There must always be two digits for hours, minutes, seconds, and hundredths; otherwise, the time it is regarded as invalid. Valid examples are “12”, “12:59”, “12:59:59”, and “12:59:59:99”. By contrast, invalid examples are “24”, “12:60”, or “12:1”, and/or “12:”. IF you work with time strings that are not completely filled and that you need to check with TimeValid(), then they must be TRIMmed prior to the use of TimeValid() (see following Examples).
Using the VALID clause with TRIM, all valid times are accepted, even IF no seconds or minutes are specIFied: cBegin := SPACE( 11 ) @ 5, 10 SAY "Please input time for beginning work:"; GET cBegin VALID TimeValid( RTRIM( cBegin ) ) READ Using a VALID clause without TRIM, hours and minutes must be specified, so that TimeValid() can confirm a valid time: cBegin := SPACE( 5 ) @ 5, 10 SAY "Please input time for beginning work:"; GET cBegin VALID TimeValid( cBegin ) READ
This function is CA-Cl*pper Tools compatible.
Source is dattime3.c, library is libct.