Formats

Any Variable can be formatted for textual display.

The variables[].format property specifies how a value should be displayed to users. The Taffrail API will automatically apply formatting in a separate field. Formats commonly apply to Number, Percent, and Date Variables.

{
 ...
 "format": "0[.]0",
 "value": 1.23,
 "valueFormatted": "1.2"
}

For more detail, go to Variables: Format.

Numbers

Our Number formatting scheme is currently based on Numeral.js.

Custom Formats

As of this version, an additional Taffrail-custom format is available to support converting regular fractions to their Unicode equivalent. For example, 1/2 becomes ½.

The Unicode fraction format (n/d) can be used in combination with Numeral number formats, like this:

  • Formatting 1.5 with the format0.0n/d would result in .
  • 1.2345 formatted as 0[.]00n/d yields 1.23.

The Numeral number format is what precedes n/d in the format string.

🚧

Numbers only

Do not attempt to format Abbreviations, Ordinals, Percentages, or Currencies with this format string, they are not supported.

Dates

Our Date formatting scheme is based on Date-Fns.