Units
Package for converting and formatting units and numerical values.
npm install @dynatrace-sdk/units
Functions
abbreviateNumber
Abbreviates large numbers into a shorter format with metric prefixes.
Parameters
Name | Type | Description |
---|---|---|
input*required | number | Number to be abbreviated |
scale*required | Scale | Scale configuration for abbreviation:
|
options*required | AdjustFractionDigitsOptions | Formatting options:
|
Returns
Description |
---|
Object containing:
|
Code example
// Basic decimal abbreviation
abbreviateNumber(1500)
// Returns: { formattedValue: '2', postfix: 'k' }
Code example
// Binary (bytes) abbreviation
abbreviateNumber(1048576, ExponentialOctalByteLevels)
// Returns: { formattedValue: '1', postfix: 'MiB' }
Code example
// Custom fraction digits
abbreviateNumber(1500000, ExponentialDecimalLevels, { maximumFractionDigits: 2 })
// Returns: { formattedValue: '1.50', postfix: 'M' }
adjustFractionDigits
Formats a number with precise control over decimal places and handles very small values.
Parameters
Name | Type | Description |
---|---|---|
input*required | number | The number to format |
options | AdjustFractionDigitsOptions | Formatting configuration:
|
Returns
Description |
---|
Formatted number string, with special handling for very small values:
|
Code example
// Basic formatting
adjustFractionDigits(1234.5678, { maximumFractionDigits: 2 })
// Returns: '1,234.57'
Code example
// Format with custom locale
adjustFractionDigits(1234.5, { locale: 'de-DE', maximumFractionDigits: 1 })
// Returns: '1.234,5'
Code example
// Handle very small values
adjustFractionDigits(0.0000001, { maximumFractionDigits: 3 })
// Returns: '< 0.001'
convert
Converts a numeric value from one unit to another within the same measurement system
Parameters
Name | Type | Description |
---|---|---|
input*required | number | The numeric value to convert |
from*required | FromUnit | Source unit (e.g., units.length.meter, units.time.second) |
to*required | ConvertibleTarget<FromUnit | ToUnit> | Target unit for conversion (must be compatible with source unit) |
Returns
Description |
---|
Converted numeric value |
Throws
Error Type | Error Message |
---|---|
undefined | Error if units are incompatible (different measurement systems) |
Code example
// Convert length
import { convert, units } from "@dynatrace-sdk/units";
convert(1500, units.length.meter, units.length.kilometer)
// Returns: 1.5
Code example
// Convert temperature
convert(32, units.temperature.degree_fahrenheit, units.temperature.degree_celsius)
// Returns: 0
Code example
// Convert time
convert(3600, units.time.second, units.time.hour)
// Returns: 1
format
Converts and formats a numeric value using units and formatting options.
Parameters
Name | Type | Description |
---|---|---|
number*required | number | The numeric value to format |
options | FormatOptions<FromUnit | ToUnit> | Formatting configuration options:
|
Returns
Description |
---|
A formatted string with the number and its unit |
Code example
// Format without units (abbreviation enabled by default)
format(1500)
// Returns: '2K'
Code example
// Format with unit conversion
format(1500, {
input: units.length.meter,
maximumFractionDigits: 1
})
// Returns: '1.5 km'
Code example
// Format with unit cascading
format(1500, {
input: units.length.meter,
cascade: 2
})
// Returns: '1 km 500 m'
formatCurrency
Formats a number according to currency and locale conventions.
Parameters
Name | Type | Description |
---|---|---|
number*required | number | The numeric value to format |
currency*required | undefined | "CHF" | "AED" | "AFN" | "ALL" | "AMD" | "ANG" | "AOA" | "ARS" | "AUD" | "AWG" | "AZN" | "BAM" | "BBD" | "BDT" | "BGN" | "BHD" | "BIF" | "BMD" | "BND" | "BOB" | "BRL" | "BSD" | "BTN" | "BWP" | "BYN" | "BZD" | "CAD" | "CDF" | "CLP" | "CNY" | "COP" | "CRC" | "CUC" | "CUP" | "CVE" | "CZK" | "DJF" | "DKK" | "DOP" | "DZD" | "EGP" | "ERN" | "ETB" | "EUR" | "FJD" | "FKP" | "GBP" | "GEL" | "GHS" | "GIP" | "GMD" | "GNF" | "GTQ" | "GYD" | "HKD" | "HNL" | "HRK" | "HTG" | "HUF" | "IDR" | "ILS" | "INR" | "IQD" | "IRR" | "ISK" | "JMD" | "JOD" | "JPY" | "KES" | "KGS" | "KHR" | "KMF" | "KPW" | "KRW" | "KWD" | "KYD" | "KZT" | "LAK" | "LBP" | "LKR" | "LRD" | "LSL" | "LYD" | "MAD" | "MDL" | "MGA" | "MKD" | "MMK" | "MNT" | "MOP" | "MRU" | "MUR" | "MVR" | "MWK" | "MXN" | "MYR" | "MZN" | "NAD" | "NGN" | "NIO" | "NOK" | "NPR" | "NZD" | "OMR" | "PAB" | "PEN" | "PGK" | "PHP" | "PKR" | "PLN" | "PYG" | "QAR" | "RON" | "RSD" | "RUB" | "RWF" | "SAR" | "SBD" | "SCR" | "SDG" | "SEK" | "SGD" | "SHP" | "SLE" | "SLL" | "SOS" | "SRD" | "SSP" | "STN" | "SVC" | "SYP" | "SZL" | "THB" | "TJS" | "TMT" | "TND" | "TOP" | "TRY" | "TTD" | "TWD" | "TZS" | "UAH" | "UGX" | "USD" | "UYU" | "UZS" | "VES" | "VND" | "VUV" | "WST" | "XAF" | "XCD" | "XCG" | "XDR" | "XOF" | "XPF" | "XSU" | "YER" | "ZAR" | "ZMW" | "ZWL" | | ISO 4217 currency code (e.g., 'USD', 'EUR') |
options | FormatCurrencyOptions | Currency formatting configuration:
|
Returns
Description |
---|
Formatted currency string |
Code example
// Format with default options
formatCurrency(1500, 'USD')
// Returns: '$1.50K'
Code example
// Format with custom locale and no abbreviation
formatCurrency(1500, 'EUR', {
locale: 'de-DE',
abbreviate: false
})
// Returns: '1.500,00 €'
Code example
// Format large number with abbreviation
formatCurrency(1500000, 'USD', { abbreviate: true })
// Returns: '$1.50M'
formatDate
Formats a date according to locale and timezone settings.
Parameters
Name | Type | Description |
---|---|---|
input*required | number | Date | The date to format, as either:
|
options | FormatDateOptions | Date formatting configuration:
|
Returns
Description |
---|
Formatted date string according to locale and options |
Code example
// Format date with default locale and timezone
formatDate(new Date())
// Returns: '5/27/2025'
Code example
// Format with custom locale and timezone
formatDate(new Date(), {
locale: 'de-DE',
timeZone: 'Europe/Berlin',
dateStyle: 'full'
})
// Returns: 'Dienstag, 27. Mai 2025'
Code example
// Format timestamp with custom style
formatDate(1621344000000, {
dateStyle: 'short',
timeStyle: 'short'
})
// Returns: '5/27/25, 2:30 PM'
formatLong
Formats large numbers with precise decimal handling, useful for scientific or financial calculations.
Parameters
Name | Type | Description |
---|---|---|
value*required | string | number | bigint | The value to format. Accepts:
|
options | FormatLong | Formatting configuration:
|
Returns
Description |
---|
Formatted number string with precise decimal handling |
Code example
// Format large number
formatLong('123456789.123456789')
// Returns: '123,456,789.123'
Code example
// Format with custom locale and fraction digits
formatLong(123456.789, {
locale: 'de-DE',
maximumFractionDigits: 2
})
// Returns: '123.456,79'
Code example
// Format BigInt value
formatLong(BigInt('9007199254740991'))
// Returns: '9,007,199,254,740,991'
formatUnit
Formats a unit into a human-readable string representation.
Parameters
Name | Type | Description |
---|---|---|
unit*required | FormattableUnit | The unit to format, consisting of group, index, and exponent values |
Returns
Description |
---|
Formatted unit string |
Code example
// Format a simple unit
formatUnit([{ group: 'meter', index: 3, exponent: 1 }])
// Returns: 'km'
Code example
// Format a compound unit
formatUnit([
{ group: 'meter', index: 0, exponent: 1 },
{ group: 'hour', index: 0, exponent: '–1' }
])
// Returns: 'm/s'
Code example
// Format with exponents
formatUnit([{ group: 'meter', index: 0, exponent: 2 }])
// Returns: 'm^2'
getFormatting
Converts and formats a number into its constituent parts for flexible display.
Parameters
Name | Type | Description |
---|---|---|
number*required | number | The numeric value to format |
options | FormatOptions<FromUnit | ToUnit> | Formatting configuration options:
|
Returns
Description |
---|
An array of formatting parts, where each part contains:
|
Code example
// Format bytes with default options
getFormatting(1500)
// Returns: [{ value: '2K', symbol: '', separator: '', symbolPrefix: false }]
Code example
// Format with custom units and fraction digits
getFormatting(1500, {
input: units.length.meter,
maximumFractionDigits: 2
})
// Returns: [{ value: '1.5', symbol: 'km', separator: ' ', symbolPrefix: false }]
mapGrailUnit
Maps a Grail unit string to its corresponding units system equivalent.
Parameters
Name | Type | Description |
---|---|---|
grailUnit*required | string | The Grail unit string to convert (e.g., 'BytePerSecond') |
Returns
Description |
---|
Unit equivalency object containing:
|
Code example
// Map data transfer rate unit
mapGrailUnit('BytePerSecond')
// Returns: { 'namespace': 'datarate', 'unitName': 'Bps', 'unit': [ { 'group': 'byte_m', 'index': 0, 'exponent': 1 }, { 'group': 'second', 'index': 0, 'exponent': '–1' } ] }
parseTime
⚠️ Deprecated Use the
parseTimeAsTimeValue
function instead
Converts a string representation of time into a structured TimeDetails object.
Parameters
Name | Type | Description |
---|---|---|
null | string | Input string to parse. Supports:
| |
number | Reference timestamp for relative expressions (defaults to current time) |
Returns
Description |
---|
TimeDetails object containing:
|
Code example
// Parse ISO datetime
parseTime('2025-05-27T14:30:00Z')
// Returns: {
// normalized: '2025-05-27T14:30:00Z',
// date: Date('2025-05-27T14:30:00.000Z'),
// type: 'iso8601'
// }
Code example
// Parse relative time
parseTime('now-30m')
// Returns: {
// normalized: 'now-30m',
// date: [Date 30 minutes before current time],
// type: 'expression'
// }
Code example
// Parse date format
parseTime('2025-05-27 14:30')
// Returns: {
// normalized: '2025-05-27T14:30:00Z',
// date: Date('2025-05-27T14:30:00.000Z'),
// type: 'iso8601'
// }
parseTimeAsTimeValue
Converts various time string formats into a normalized TimeValue object.
Parameters
Name | Type | Description |
---|---|---|
candidate | null | string | Input string to parse. Supports:
|
relativeDate | number | Reference timestamp for relative expressions |
precision | "day" | "minutes" | "seconds" | "milliseconds" | Output precision level:
|
Returns
Description |
---|
TimeValue object containing:
|
Code example
// Parse ISO datetime
parseTime('2025-05-27T14:30:00Z')
// Returns: {
// type: 'iso8601',
// value: '2025-05-27T14:30:00Z',
// absoluteDate: '2025-05-27T14:30:00Z'
// }
Code example
// Parse relative time
parseTime('now-30m')
// Returns: {
// type: 'expression',
// value: 'now()-30m',
// absoluteDate: [ISO string 30 minutes before now]
// }
variantNames
Returns the names of all units to which the provided unit can be converted.
Parameters
Name | Type | Description |
---|---|---|
unit*required | U | The source unit to find convertible variants for (e.g., units.length.meter) |
Returns
Description |
---|
Array of unit names that are valid conversion targets |
Code example
// Get all length unit names
variantNames(units.length.meter)
// Returns:
// ['meter', 'kilometer', 'centimeter', 'millimeter', ...]
Code example
// Get temperature unit names
variantNames(units.temperature.degree_celsius)
// Returns:
// ['degree_celsius', 'degree_fahrenheit', ...]
variantUnits
Returns all units to which the provided unit can be converted.
Parameters
Name | Type | Description |
---|---|---|
unit*required | U | The source unit to find convertible variants for (e.g., units.length.meter) |
Returns
Description |
---|
Array of unit objects that are valid conversion targets |
Code example
// Get all length units
variantUnits(units.length.meter)
// Returns:
// [
// [{ 'group': 'meter', 'index': -15, 'exponent': 1 }],
// [{ 'group': 'meter', 'index': 30, 'exponent': 1 }],
// ...
// ]
Code example
// Get convertible temperature units
variantUnits(units.temperature.degree_celsius)
// Returns:
// [
// [{ 'group': 'degree_celsius', 'index': 0, 'exponent': 1 }],
// [{ 'group': 'degree_fahrenheit', 'index': 0, 'exponent': 1 }],
// ...
// ]
Constants
ExponentialDecimalLevels
Abbreviation levels for decimal metric prefixes from kilo to quecto, 10^3, 10^6, ...
Properites
Name | Type |
---|---|
base*required | number |
levels*required | Array<string> |
ExponentialOctalBitLevels
Abbreviation levels for bit binary prefixes from kilobit to quebibit, 2^10, 2^20, ...
Properites
Name | Type |
---|---|
base*required | number |
levels*required | Array<string> |
ExponentialOctalByteLevels
Abbreviation levels for byte binary prefixes from kibibyte to quebibyte, 2^10, 2^20, ...
Properites
Name | Type |
---|---|
base*required | number |
levels*required | Array<string> |
timeframeTranslations
Properites
Name | Type |
---|---|
M*required | (intl: IntlShape, values: { offset, prefix, suffix }) => string |
d*required | (intl: IntlShape, values: { offset, prefix, suffix }) => string |
full-day*required | (intl: IntlShape) => string |
h*required | (intl: IntlShape, values: { offset, prefix, suffix }) => string |
m*required | (intl: IntlShape, values: { offset, prefix, suffix }) => string |
ms*required | (intl: IntlShape, values: { offset, prefix, suffix }) => string |
now*required | (intl: IntlShape) => string |
q*required | (intl: IntlShape, values: { offset, prefix, suffix }) => string |
remaining-day*required | (intl: IntlShape) => string |
roundDown-M*required | (intl: IntlShape, values: { amount, prefix }) => string |
roundDown-d*required | (intl: IntlShape, values: { amount, prefix }) => string |
roundDown-h*required | (intl: IntlShape, values: { amount, prefix }) => string |
roundDown-m*required | (intl: IntlShape, values: { amount, prefix }) => string |
roundDown-q*required | (intl: IntlShape, values: { amount, prefix }) => string |
roundDown-s*required | (intl: IntlShape, values: { amount, prefix }) => string |
roundDown-w*required | (intl: IntlShape, values: { amount, prefix }) => string |
roundDown-y*required | (intl: IntlShape, values: { amount, prefix }) => string |
s*required | (intl: IntlShape, values: { offset, prefix, suffix }) => string |
to*required | (intl: IntlShape) => string |
today*required | (intl: IntlShape) => string |
tomorrow*required | (intl: IntlShape) => string |
w*required | (intl: IntlShape, values: { offset, prefix, suffix }) => string |
y*required | (intl: IntlShape, values: { offset, prefix, suffix }) => string |
yesterday*required | (intl: IntlShape) => string |
units
Grouped collection of all the supported units
Properites
Name | Type |
---|---|
acceleration*required | { foot_per_second_squared, meter_per_second_squared } |
amount*required | { mole, one } |
angle*required | { degree, milliradian, minute, radian, revolution, second } |
area*required | { square_attometer, square_centimeter, square_decimeter, square_femtometer, square_foot, square_inch, square_kilometer, square_meter, square_micrometer, square_mile, square_millimeter, square_nanometer, square_picometer, square_yard, square_yoctometer, square_zeptometer } |
{ aud, cad, chf, cny, eur, gbp, jpy, nzd, usd } | |
data*required | { bit, bit_binary, byte, byte_binary, exabit, exabyte, exibit, exibyte, gibibit, gibibyte, gigabit, gigabyte, kibibit, kibibyte, kilobit, kilobyte, mebibit, mebibyte, megabit, megabyte, pebibit, pebibyte, petabit, petabyte, quebibit, quebibyte, quettabit, quettabyte, robibit, robibyte, ronnabit, ronnabyte, tebibit, tebibyte, terabit, terabyte, yobibit, yobibyte, yottabit, yottabyte, zebibit, zebibyte, zettabit, zettabyte } |
datarate*required | { Bph, Bpm, Bps, GBph, GBpm, GBps, Gbitph, Gbitpm, Gbitps, GiBph, GiBpm, GiBps, Gibitph, Gibitpm, Gibitps, MBph, MBpm, MBps, Mbitph, Mbitpm, Mbitps, MiBph, MiBpm, MiBps, Mibitph, Mibitpm, Mibitps, bitph, bitpm, bitps, kBph, kBpm, kBps, kbitph, kbitpm, kbitps, kiBph, kiBpm, kiBps, kibitph, kibitpm, kibitps } |
electricity*required | { ampere, attoampere, attocoulomb, attofarad, attohenry, attoohm, attosiemens, attotesla, attovolt, attowatt, attoweber, centiampere, centicoulomb, centifarad, centihenry, centiohm, centisiemens, centitesla, centivolt, centiwatt, centiweber, coulomb, decaampere, decacoulomb, decafarad, decahenry, decaohm, decasiemens, decatesla, decavolt, decawatt, decaweber, deciampere, decicoulomb, decifarad, decihenry, deciohm, decisiemens, decitesla, decivolt, deciwatt, deciweber, exaampere, exacoulomb, exafarad, exahenry, exaohm, exasiemens, exatesla, exavolt, exawatt, exaweber, farad, femtoampere, femtocoulomb, femtofarad, femtohenry, femtoohm, femtosiemens, femtotesla, femtovolt, femtowatt, femtoweber, gigaampere, gigacoulomb, gigafarad, gigahenry, gigaohm, gigasiemens, gigatesla, gigavolt, gigawatt, gigaweber, hectoampere, hectocoulomb, hectofarad, hectohenry, hectoohm, hectosiemens, hectotesla, hectovolt, hectowatt, hectoweber, henry, kiloampere, kilocoulomb, kilofarad, kilohenry, kiloohm, kilosiemens, kilotesla, kilovolt, kilowatt, kiloweber, megaampere, megacoulomb, megafarad, megahenry, megaohm, megasiemens, megatesla, megavolt, megawatt, megaweber, microampere, microcoulomb, microfarad, microhenry, microohm, microsiemens, microtesla, microvolt, microwatt, microweber, milliampere, millicoulomb, millifarad, millihenry, milliohm, millisiemens, millitesla, millivolt, milliwatt, milliweber, nanoampere, nanocoulomb, nanofarad, nanohenry, nanoohm, nanosiemens, nanotesla, nanovolt, nanowatt, nanoweber, ohm, petaampere, petacoulomb, petafarad, petahenry, petaohm, petasiemens, petatesla, petavolt, petawatt, petaweber, picoampere, picocoulomb, picofarad, picohenry, picoohm, picosiemens, picotesla, picovolt, picowatt, picoweber, quectoampere, quectocoulomb, quectofarad, quectohenry, quectoohm, quectosiemens, quectotesla, quectovolt, quectowatt, quectoweber, quettaampere, quettacoulomb, quettafarad, quettahenry, quettaohm, quettasiemens, quettatesla, quettavolt, quettawatt, quettaweber, ronnaampere, ronnacoulomb, ronnafarad, ronnahenry, ronnaohm, ronnasiemens, ronnatesla, ronnavolt, ronnawatt, ronnaweber, rontoampere, rontocoulomb, rontofarad, rontohenry, rontoohm, rontosiemens, rontotesla, rontovolt, rontowatt, rontoweber, siemens, teraampere, teracoulomb, terafarad, terahenry, teraohm, terasiemens, teratesla, teravolt, terawatt, teraweber, tesla, volt, watt, weber, yoctoampere, yoctocoulomb, yoctofarad, yoctohenry, yoctoohm, yoctosiemens, yoctotesla, yoctovolt, yoctowatt, yoctoweber, yottaampere, yottacoulomb, yottafarad, yottahenry, yottaohm, yottasiemens, yottatesla, yottavolt, yottawatt, yottaweber, zeptoampere, zeptocoulomb, zeptofarad, zeptohenry, zeptoohm, zeptosiemens, zeptotesla, zeptovolt, zeptowatt, zeptoweber, zettaampere, zettacoulomb, zettafarad, zettahenry, zettaohm, zettasiemens, zettatesla, zettavolt, zettawatt, zettaweber } |
energy*required | { attojoule, attowatt_hour, centijoule, centiwatt_hour, decajoule, decawatt_hour, decijoule, deciwatt_hour, exajoule, exawatt_hour, femtojoule, femtowatt_hour, gigajoule, gigawatt_hour, hectojoule, hectowatt_hour, joule, kilojoule, kilowatt_hour, megajoule, megawatt_hour, microjoule, microwatt_hour, millijoule, milliwatt_hour, nanojoule, nanowatt_hour, petajoule, petawatt_hour, picojoule, picowatt_hour, quectojoule, quectowatt_hour, quettajoule, quettawatt_hour, ronnajoule, ronnawatt_hour, rontojoule, rontowatt_hour, terajoule, terawatt_hour, watt_hour, yoctojoule, yoctowatt_hour, yottajoule, yottawatt_hour, zeptojoule, zeptowatt_hour, zettajoule, zettawatt_hour } |
force*required | { attonewton, centinewton, decanewton, decinewton, exanewton, femtonewton, giganewton, hectonewton, kilonewton, meganewton, micronewton, millinewton, nanonewton, newton, petanewton, piconewton, pound, quectonewton, quettanewton, ronnanewton, rontonewton, teranewton, yoctonewton, yottanewton, zeptonewton, zettanewton } |
frequency*required | { attohertz, centihertz, decahertz, decihertz, exahertz, femtohertz, gigahertz, hectohertz, hertz, kilohertz, megahertz, microhertz, millihertz, nanohertz, petahertz, picohertz, quectohertz, quettahertz, ronnahertz, rontohertz, terahertz, yoctohertz, yottahertz, zeptohertz, zettahertz } |
length*required | { astronomical_unit, attometer, centimeter, decameter, decimeter, exameter, femtometer, foot, gigameter, hectometer, inch, kilometer, lightyear, megameter, meter, micrometer, mile, millimeter, nanometer, petameter, picometer, quectometer, quettameter, ronnameter, rontometer, terameter, yard, yoctometer, yottameter, zeptometer, zettameter } |
level*required | { decibel_milliwatt } |
{ attoliter, attolitre, centiliter, centilitre, decaliter, decalitre, deciliter, decilitre, exaliter, exalitre, femtoliter, femtolitre, gigaliter, gigalitre, hectoliter, hectolitre, kiloliter, kilolitre, liter, litre, megaliter, megalitre, microliter, microlitre, milliliter, millilitre, nanoliter, nanolitre, petaliter, petalitre, picoliter, picolitre, quectoliter, quectolitre, quettaliter, quettalitre, ronnaliter, ronnalitre, rontoliter, rontolitre, teraliter, teralitre, yoctoliter, yoctolitre, yottaliter, yottalitre, zeptoliter, zeptolitre, zettaliter, zettalitre } | |
load*required | { millisecond_per_minute, nanosecond_per_minute, second_per_minute } |
mass*required | { attogram, centigram, decagram, decigram, exagram, femtogram, gigagram, grain, gram, hectogram, kilogram, megagram, microgram, milligram, nanogram, ounce, petagram, picogram, pound, quectogram, quettagram, ronnagram, rontogram, teragram, tonne, yoctogram, yottagram, zeptogram, zettagram } |
percentage*required | { one, parts_per_billion, parts_per_million, parts_per_trillion, per_mille, percent, promille } |
physics*required | { attocandela, attogray, attolumen, attolux, attosievert, attosteradian, candela, centicandela, centigray, centilumen, centilux, centisievert, centisteradian, decacandela, decagray, decalumen, decalux, decasievert, decasteradian, decicandela, decigray, decilumen, decilux, decisievert, decisteradian, exacandela, exagray, exalumen, exalux, exasievert, exasteradian, femtocandela, femtogray, femtolumen, femtolux, femtosievert, femtosteradian, gigacandela, gigagray, gigalumen, gigalux, gigasievert, gigasteradian, gray, hectocandela, hectogray, hectolumen, hectolux, hectosievert, hectosteradian, kilocandela, kilogray, kilolumen, kilolux, kilosievert, kilosteradian, lumen, lux, megacandela, megagray, megalumen, megalux, megasievert, megasteradian, microcandela, microgray, microlumen, microlux, microsievert, microsteradian, millicandela, milligray, millilumen, millilux, millisievert, millisteradian, nanocandela, nanogray, nanolumen, nanolux, nanosievert, nanosteradian, petacandela, petagray, petalumen, petalux, petasievert, petasteradian, picocandela, picogray, picolumen, picolux, picosievert, picosteradian, quectocandela, quectogray, quectolumen, quectolux, quectosievert, quectosteradian, quettacandela, quettagray, quettalumen, quettalux, quettasievert, quettasteradian, ronnacandela, ronnagray, ronnalumen, ronnalux, ronnasievert, ronnasteradian, rontocandela, rontogray, rontolumen, rontolux, rontosievert, rontosteradian, sievert, steradian, teracandela, teragray, teralumen, teralux, terasievert, terasteradian, yoctocandela, yoctogray, yoctolumen, yoctolux, yoctosievert, yoctosteradian, yottacandela, yottagray, yottalumen, yottalux, yottasievert, yottasteradian, zeptocandela, zeptogray, zeptolumen, zeptolux, zeptosievert, zeptosteradian, zettacandela, zettagray, zettalumen, zettalux, zettasievert, zettasteradian } |
pressure*required | { attopascal, bar, centipascal, decapascal, decipascal, exapascal, femtopascal, gigapascal, hectopascal, kilopascal, megapascal, micropascal, millipascal, nanopascal, pascal, petapascal, picopascal, psi, quectopascal, quettapascal, ronnapascal, rontopascal, terapascal, yoctopascal, yottapascal, zeptopascal, zettapascal } |
ratio*required | { attobel, bel, centibel, decabel, decibel, exabel, femtobel, gigabel, hectobel, kilobel, megabel, microbel, millibel, nanobel, petabel, picobel, quectobel, quettabel, ronnabel, rontobel, terabel, yoctobel, yottabel, zeptobel, zettabel } |
temperature*required | { degree_celsius, degree_fahrenheit, degree_rankine, kelvin } |
time*required | { attosecond, centisecond, day, decasecond, decisecond, exasecond, femtosecond, gigasecond, hectosecond, hour, kilosecond, megasecond, microsecond, millisecond, minute, month, nanosecond, petasecond, picosecond, quectosecond, quettasecond, ronnasecond, rontosecond, second, terasecond, week, year, yoctosecond, yottasecond, zeptosecond, zettasecond } |
time_squared*required | { second_squared, square_second } |
unspecified*required | { core, count, count_per_hour, count_per_minute, count_per_request, count_per_second, gigapixel, megapixel, millicore, msu, none, pixel, ratio, state, unspecified } |
velocity*required | { kilometer_per_hour, meter_per_hour, meter_per_second, miles_per_hour } |
volume*required | { attoliter, attolitre, centiliter, centilitre, cubic_decimeter, cubic_foot, cubic_inch, cubic_meter, decaliter, decalitre, deciliter, decilitre, exaliter, exalitre, femtoliter, femtolitre, gigaliter, gigalitre, hectoliter, hectolitre, kiloliter, kilolitre, liter, litre, megaliter, megalitre, microliter, microlitre, milliliter, millilitre, nanoliter, nanolitre, petaliter, petalitre, picoliter, picolitre, quectoliter, quectolitre, quettaliter, quettalitre, ronnaliter, ronnalitre, rontoliter, rontolitre, teraliter, teralitre, yoctoliter, yoctolitre, yottaliter, yottalitre, zeptoliter, zeptolitre, zettaliter, zettalitre } |
Types
AdjustFractionDigitsOptions
Properties
Name | Type | Description |
---|---|---|
locale | string | Array<string> | The locale according to which the number will be adjusted. |
maximumFractionDigits | number | Maximum number of decimal digits. |
maximumSignificantDigits | number | Maximum number of significant digits. Default is 21 |
minimumFractionDigits | number | Minimum number of decimal digits. |
minimumSignificantDigits | number | Minimum number of significant digits. Default is 1 |
useGrouping | boolean | Whether to use grouping separators, such as thousands separators or thousand/lakh/crore separators. |
FormatCurrencyOptions
Properties
Name | Type | Description |
---|---|---|
abbreviate | boolean | It will shorten the number to a shorter format. (e.g. |
locale | string | Array<string> | The locale according to which the number will be formatted. |
FormatDateOptions
Interface that extends Intl.DateTimeFormatOptions to pass an optional property to overwrite the default locale. See MDN.
Properties
Name | Type | Description |
---|---|---|
locale | string | Array<string> | The locale according to which the number will be formatted. |
FormatOptions
Properties
Name | Type | Description |
---|---|---|
abbreviate | boolean | It will shorten the number to a shorter format. (e.g. |
cascade | number | Will search for the biggest unit within its group and cascade it down the the specified depth. The last number will get rounded to |
input | FromUnit | If input unit is defined, it will convert it to the best fitting unit. (e.g. |
locale | string | Array<string> | The locale that will be used to format the number. By default it will use the platform locale specified by the user. |
maximumFractionDigits | number | The amount of maximumFractionDigits points. See MDN. If minimumFractionDigits is passed, set to minimumFractionDigits by default. Otherwise set to 0 by default. |
maximumSignificantDigits | number | Maximum number of significant digits. Default is 21 |
minimumFractionDigits | number | The amount of minimumFractionDigits points. See MDN. |
minimumSignificantDigits | number | Minimum number of significant digits. Default is 1 |
output | OutputUnit<UndefinedCoalescing<FromUnit | > | ToUnit> | If not specified, the conversion is disabled (e.g. |
suffix | string | A custom suffix that overwrites the unit symbol. |
useGrouping | boolean | Whether to use grouping separators, such as thousands separators or thousand/lakh/crore separators See MDN |