Caplin Trader 4.8.0

Class: module:br/parsing/LocalisedDateParser

module:br/parsing/LocalisedDateParser

Matches a date string and converts it to a specified output format. This supersedes module:br/parsing/DateParser, which although it does provide localisation, is not completely reliable.

LocalisedDateParser is typically used with Presenter, but can be invoked programmatically. It can make use of Moment.js localized formats for input and output.

new LocalisedDateParser().parse('09/08/2000', {inputFormats: ['MM/DD/YYYY'], outputFormat: 'LL'})

It uses Moment.js locale configuration to parse localized dates.

See module:br/formatting/LocalisedDateFormatter for the complementary formatter.

Constructor

new module:br/parsing/LocalisedDateParser()

Implements:

Methods

isSingleUseParser()

Implements:

parse(date, attributes) → {string}

Matches a date string and converts it to a specified output format.
Parameters:
Name Type Description
date string The date to parse
attributes object Map of configuration options
Properties
Name Type Attributes Default Description
inputFormats Array.<string> The possible input formats, expressed with Moment.js format tokens
outputFormat string The output format, expressed with Moment.js format tokens
inputLocale string <optional>
Locale override for the input
outputLocale string <optional>
Locale override for the output
endOfUnit boolean <optional>
false If true, parse ambiguous dates to the end of the month or year
Implements:
Returns:
The date, expressed in the output format
Type
string