Format a number
as a string
represented as a currency e.g. $123.31
const amount = 123.321
const text = localisationService.formatCurrency(amount)
// Display text
Format a Date
as a string
that just contains the date portion e.g.
31/01/2020
const date = new Date()
const text = localisationService.formatDate(date)
// Display text
Format a Date
as a string
that just contains the date portion in a long
format e.g. Thursday, 2 January 2020
const date = new Date()
const text = localisationService.formatDateLong(date)
// Display text
Format a Date
as a string
that contains the date and time portions e.g.
31/01/2020 5:31 pm
const date = new Date()
const text = localisationService.formatDatetime(date)
// Display text
Format a Date
as a string
that contains the date and time portions in a
long format e.g. Thursday, 2 January 2020 5:31 pm
const date = new Date()
const text = localisationService.formatDatetime(date)
// Display text
Format a number
as a string
represented as a readable number e.g.
123,321.123
const amount = 1234.4321
const text = localisationService.formatCurrency(amount)
// Display text
Format a Date
as a string
that just contains the time portion e.g. 5:31
pm
const date = new Date()
const text = localisationService.formatTime(date)
// Display text
Generate a Date
based a string
while adding/subtracting a number of days.
Use this function to generate a date with the correct time if only the date
part is required to be formatted for display purposes. Also supports passing
'NOW'
as the value to get the current date with an offset.
const dateOnly = localisationService.generateDate({
value: '2023-05-04',
dateOnly: true,
daysOffset: undefined,
})
const date = localisationService.generateDate({
value: '2023-05-04T02:49:23.616Z',
dateOnly: false,
daysOffset: undefined,
})
const now = localisationService.generateDate({
value: 'NOW',
dateOnly: false,
daysOffset: undefined,
})
Get the locale (e.g. en-AU
) for the current tenant.
const locale = localisationService.getLocale()
Replace the {ELEMENT:<elementName>}
values in text while a form is being
filled out. The replacements are suppose to be user friendly and for display
purposes, e.g. dates should be displayed in the user's desired format and
timezone.
Replace the {ELEMENT:<elementName>}
values in text after a successful form
submission as well as other replaceable parameters e.g. submissionId
. The
replacements are suppose to be user friendly and for display purposes, e.g.
dates should be displayed in the user's desired format and timezone.
Localisation Service
Helper functions for handling all things locale.