Skip to content

Formatters

Below is a list of importable functions that are found in the applications/global/front-end/js directory.

They can be imported individually like so:

js
{ enPascalToKebab } from '@global/js/customFilterFunctions'

They are also globally installed as mixins in Vue so there is no need to import them within Vue apps and they can be used directly in the template tags.


enFormatDateToLocal - function

Takes a datetime UTC string and will convert it to a formatted local date and time

Params
NameTypeDescription
valuestring
Returns

mm/dd/yyyy hh:mm:ss


enFormatDate - function

Formats a datetime string, format can be customized by passing in DateTimeFormat options. Removes UTC information so that the date displayed is always the same despite timezone.

Params
NameTypeDescription
datestring

date string

optionsobject

date time component options

Returns

mm/dd/yyyy


enFormatJsonDate - function

Formats a datetime string, defaults to 2 digit year format

Params
NameTypeDescription
valuestring

date string

displayFullYearboolean

changes to 4 digit year format

Returns

mm/dd/yy


enFormatJsonDatetime - function

Formats a datetime string to a date and time, defaults to 2 digit year format, removes any UTC information

Params
NameTypeDescription
valuestring

date string

displayFullYearboolean

changes to 4 digit year format

Returns

mm/dd/yy hh:mm:ss


enFormatMoney - function

Formats number value to a currency, adding dollar symbol and comma separators

Params
NameTypeDescription
valuenumberstring

if a string is passed, function will try to convert it to a number

decimalPlacesnumber

number of decimal places to show

Returns

$###,### or ""


enFormatWholeMoney - function

Similar to enFormatMoney, but trims trailing .00 and will also return $0 instead of an empty string

Params
NameTypeDescription
value*

if a string is passed, function will try to convert it to a number

decimalPlaces*

number of decimal places to show

Returns

$###,### or $0


enFormatPercent - function

Adds a percent symbol to the end of the value

Params
NameTypeDescription
valuestringnumber
Returns

##%


enBoolToYesNo - function

Converts a boolean value to "Yes" or "No"

Params
NameTypeDescription
valueboolean
Returns

Yes or No


enFormatPhone - function

Converts a string to a formatted phone number

Params
NameTypeDescription
valuestring
Returns

(###) ###-####


enFormatTaxId - function

Converts a string of numbers to a formatted Tax ID

Params
NameTypeDescription
valuestring
Returns

##-#######


enTruncate - function

Shortens the length of a string if the length is greater than the maxLength value and appends an ellipsis to the end

Params
NameTypeDescription
stringstring
maxLengthnumber
Returns

truncated string if longer than max length


dateDelta - function

Displays the time elapsed between 2 dates

Params
NameTypeDescription
fromDateDate
toDateDate

(default now)

roundToDigitnumber

(default 0) Will round the least significant date unit disccovered to this many digits

preciseTonumber

(default '') Will resolve down to provided value, '' will yield only the most significant date unit discovered

Returns

string display of the time elapsed


enCalcAge - function

Function that will return an age from a date

Params
NameTypeDescription
datestring

date string that can be parsed by Date()

defaultValnumberstring

return value for if the date passed in is null, empty, or cannot be parsed

Returns

age as a number


enPascalToKebab - function

Function that will convert PascalCase to kebab-case.

Params
NameTypeDescription
stringstring

string to convert

Returns

sortByKey - function

Function used by .sort on an array of objects to sort by a specific key

Params
NameTypeDescription
keystring
Returns

filterObjectsByString - function

Function used to filter a list of objects using a string match on all the keys in the object.

Params
NameTypeDescription
listarray.<object>
searchStringstring
Returns

filtered list