Module: Lexicon

Methods


<static> findPattern(expression)

Tries to extract a pattern from the given expression.
Parameters:
Name Type Description
expression String Expression to be analysed
Returns:
Extracted pattern
Type
String
Example
Kairos.Lexicon.findPattern('01:05:30');

<static> format(instance [, pattern], allowOverflow)

Returns a formated string from an Kairos.Engine instance. You can escape any character by using \ before it.
Parameters:
Name Type Argument Description
instance Kairos.Engine The instance to format
pattern String <optional>
Pattern to format
allowOverflow Boolean If true, when hour field is bigger than the pattern definition, it will be printed anyway
Returns:
Formated time expression
Type
String
Example
Kairos.Lexicon.format(Kairos.new('10:30'), 'mm:hh');

<static> getValidator( [pattern])

Gets a regex from a pattern.
Parameters:
Name Type Argument Description
pattern String <optional>
Pattern to convert
Returns:
Type
RegExp
Example
Kairos.Lexicon.getValidator('#hh:mm:ss.SSS');

<static> parse(expression [, pattern])

Parses given time expression to a Kairos.Engine instance.
Parameters:
Name Type Argument Description
expression String Time expression to be parsed
pattern String <optional>
Pattern to parse
Returns:
Given expression parsed to Kairos.Engine
Type
Kairos.Engine
Example
Kairos.Lexicon.parse('01:00:03', 'hh:mm:ss');

<static> validate(expression [, pattern])

Validates if given expression matches the current pattern.
Parameters:
Name Type Argument Description
expression String Time expression to be validated
pattern String <optional>
Pattern to validate
Returns:
True if expression is valid, false if expression is invalid
Type
Boolean
Example
Kairos.Lexicon.validate('10:00:00.000', 'hh:mm:ss.SSS');