Skip to content

isTime

The isTime() function checks that a string matches the TheTime format (time<timestamp><"-" | "+">). It acts as a type guard.

Interactive example

Syntax

typescript
function isTime(input: string): input is TheTime

Parameters

  • input: String to validate.

Return value

true if the string follows the TheTime format, otherwise false. When true, TypeScript narrows input to TheTime.

See also

  • createTime - Builds a TheTime from native values
  • is - Checks the TheDate format

Released under the MIT license.