Skip to content

time

DDataParser.time() validates TheTime durations. It natively accepts TheTime, SerializedTheTime, and safe numeric values. In coercive mode (coerce: true), it also accepts ISO-like time strings (HH:MM[:SS[.mmm]]).

Interactive example

Parameters

  • errorMessage: custom message when the input cannot be converted to TheTime.
  • checkers: checkerTimeMin, checkerTimeMax, checkerRefine, etc.
  • coerce: true to accept a number (ms) or an ISO string (HH:MM[:SS[.mmm]]) before converting to TheTime. Defaults to false.

Return value

A DataParserTime with parse, asyncParse, exec, asyncExec, addChecker, clone. parse returns DEither.success<TheTime> if everything passes or DEither.error<DataParserError> with the accumulated issues.

In extended mode (DPE.time()), .min(...) and .max(...) respectively add checkerTimeMin and checkerTimeMax.

Other examples

Custom checkers

Extended mode

See also

  • date - Parser for dates
  • coerce.* - Coercion functions for various types

Released under the MIT license.