$formatter
Updated on Aug 25, 2025 3 minutes to readThe Formatter Plugin provides methods to format dates, times, timestamps, booleans, and numbers according to locale and custom format options. It helps normalize values for display across the application.
Methods
Method | Description |
---|---|
asBoolean | Formats a value as a localized boolean string. |
asDate | Formats a value as a localized date string. |
asNumber | Formats a numeric value according to locale and options. |
asTime | Formats a value as a localized time string. |
asTimestamp | Formats a timestamp as a localized date-time string. |
Methods Details
asBoolean()
• Type
(value: any, format?: string) => string
• Details
If the value is filled (truthy in JavaScript), the method returns the localized representation of true.
If the value is empty (falsy), it returns the localized representation of false.
If no format is provided, the method defaults to localized Yes
for true and No
for false.
asDate()
• Type
(value: any, format?: string) => string
• Details
If the value is filled (valid Date, number, or date string), the method returns the localized date string.
If the value is empty or invalid, it returns a default empty text (—
) or the emptyText specified in the format.
asNumber()
• Type
(value: any, format?: string) => string
• Details
If the value is filled (numeric or coercible to number), the method returns the localized number string, applying decimal, thousand separators, precision, symbol, and positive/negative/zero formats if specified.
If the value is empty or invalid, it returns a default empty text (—
) or the emptyText specified in the format.
asTime()
• Type
(value: any, format?: string) => string
• Details
If the value is filled (valid Date, number, or time string), the method returns the localized time string.
If the value is empty or invalid, it returns a default empty text (—
) or the emptyText specified in the format.
asTimestamp()
• Type
(value: any, format?: string) => string
• Details
If the value is filled (Unix timestamp, Date object, or timestamp string), the method returns the localized date-time string with timezone applied.
If the value is empty or invalid, it returns a default empty text (—
) or the emptyText specified in the format.