Caplin Trader 5.1.0

Class: module:ct-element/parser/DateParser

module:ct-element/parser/DateParser()

new module:ct-element/parser/DateParser()

Matches a date string and converts it to a specified output format.

DateParser is typically used in the XML Renderer Framework, but can be invoked programmatically as in the following example which evaluates to '08-Sep-2000'

DateParser.parse('09/08/2000', {american:'true', outputFormat:'d-M-Y'})

See @link module:ct-element/formatter/DateFormatter} for the complementary formatter.
Implements:

Methods

parse(vValue, mAttributes) → {String}

Matches a date string and converts it to a specified output format.

In order to match the date, either a list of explicit inputFormats can be supplied, or an american indicator can be used against a set of standard formats, which are as follows:

American: m-d-Y, m-d-y, M-d-Y, M-d-y, m-d
European: d-m-Y, d-m-Y, d-M-Y, d-M-Y, d-m

Parameters:
Name Type Attributes Default Description
vValue Variant

the date to parse (String).

mAttributes Map

the map of attributes.

mAttribute.american boolean <optional>
false

if true, dates are assumed to be in American format

mAttributes.separators String <optional>
'\/.-'

a set of admissible separator characters.

mAttributes.inputFormats String

a comma separated list of admissible input formats.

mAttributes.outputFormat String

the output date format.

Returns:

the date, expressed in the output format

Type
String