Caplin Trader 4.7.1

Class: module:br/formatting/LocalisedDateFormatter

module:br/formatting/LocalisedDateFormatter

Formats a date value by converting it from a specified input format to a new output format. This supersedes br/formatting/DateFormatter, which although it does provide localisation, is not completely reliable.

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

new LocalisedDateFormatter().format('20150525', {inputFormat:'YYYYMMDD' outputFormat: 'LL'})

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

See module:br/parsing/LocalisedDateParser for the complementary parser.

Constructor

new module:br/formatting/LocalisedDateFormatter()

Implements:

Methods

format(date, attributes) → {string}

Formats a date by converting it from a specified input format to a new output format.
Parameters:
Name Type Description
date string The input date
attributes object Map of configuration options
Properties
Name Type Attributes Default Description
inputFormat string Format of the input date, expressed with Moment.js format tokens
outputFormat string <optional>
'L' Format of the output date, expressed with Moment.js format tokens
inputLocale string <optional>
Locale override for the input
outputLocale string <optional>
Locale override for the output
Implements:
Returns:
The date expressed in the output format, or the input value if it could not be parsed in the input format
Type
string