Caplin Trader 5.1.0

Class: module:br-formatting/DateFormatter

module:br-formatting/DateFormatter()

Formats a date value by converting it from a specified input format to a new output format.

DateFormatter is typically used with Presenter, but can be invoked programmatically as in the following examples which evaluate to "09-Sep-2001 01:46:40" and "2001Sep09" respectively:

new DateFormatter().format(1e12, {inputFormat:"U"})
new DateFormatter().format(1e12, {inputFormat:"U", outputFormat:"YMd"})

See module:br-presenter/parser/DateParser for the complementary parser.

Constructor

new module:br-formatting/DateFormatter()

Implements:
Deprecated:

Methods

format(vValue, mAttributes)

Formats a date by converting it from a specified input format to a new output format.

Parameters:
Name Type Description
vValue string | Date

the input date

mAttributes object

the map of attributes.

Properties
Name Type Attributes Default Description
inputFormat string <optional>
'DD-MM-YYYY HH:mm:ss'

format of the input date, expressed with Moment.js format tokens

outputFormat string <optional>
'DD-MM-YYYY HH:mm:ss'

format of the output date, expressed with Moment.js format tokens

adjustForTimezone boolean <optional>
false

whether the formatter should adjust the date according to the client's timezone

Implements:
Returns:

the output date.