Skip to content

IsTimeSpanValid

See Also: Time and Date Functions

Purpose

This function returns True if the passed TimeSpan variable is valid. It tests that all of the parts of the time span fit within the allowable range for that part.

Return Type

Boolean

Syntax

(IsTimeSpanValid({tsVar}))

Parameters

Example 1

This sample initializes a valid TimeSpan variable and tests its validity.

Procedure Test
    TimeSpan tsVar
    Move (DateSetSecond(tsVar, 30)) to tsVar
    Move (DateSetMinute(tsVar, 10)) to tsVar
    Move (DateSetHour(tsVar, 10)) to tsVar
    Move (DateSetDay(tsVar, 30)) to tsVar
    // prints
    // The TimeSpan 30:10:10:30 is valid
    Showln "The TimeSpan " tsVar " is" (If(IsTimeSpanValid(tsVar), "", " not")) " valid"
End_Procedure

Example 2

This sample initializes an invalid TimeSpan variable (there can't be more than 23 hours) and tests its validity.

Procedure Test
    TimeSpan tsVar
    Move (DateSetSecond(tsVar, 30)) to tsVar
    Move (DateSetMinute(tsVar, 10)) to tsVar
    Move (DateSetHour(tsVar, 30)) to tsVar  // too many hours
    Move (DateSetDay(tsVar, 30)) to tsVar
    // prints
    // The TimeSpan 30:10:30:30 is not valid
    Showln "The TimeSpan " tsVar " is" (If(IsTimeSpanValid(tsVar), "", " not")) " valid"
End_Procedure