RelativeTimeFormat

@native @JSType trait RelativeTimeFormat extends StObject
Companion
object
trait StObject
class Object
trait Any
class Object
trait Matchable
class Any

Value members

Concrete methods

def format(value: Double, unit: RelativeTimeFormatUnit): String

Formats a value and a unit according to the locale and formatting options of the given Intl.RelativeTimeFormat object.

Formats a value and a unit according to the locale and formatting options of the given Intl.RelativeTimeFormat object.

While this method automatically provides the correct plural forms, the grammatical form is otherwise as neutral as possible. It is the caller's responsibility to handle cut-off logic such as deciding between displaying "in 7 days" or "in 1 week". This API does not support relative dates involving compound units. e.g "in 5 days and 4 hours".

Value Params
unit
  • Unit to use in the relative time internationalized message. Possible values are: "year", "quarter", "month", "week", "day", "hour", "minute", "second". Plural forms are also permitted.
value
  • Numeric value to use in the internationalized relative time message
Throws
`RangeError`

if unit was given something other than unit possible values

A version of the format method which it returns an array of objects which represent "parts" of the object, separating the formatted number into its constituent parts and separating it from other surrounding text. These objects have two properties: type a NumberFormat formatToParts type, and value, which is the String which is the component of the output. If a "part" came from NumberFormat, it will have a unit property which indicates the unit being formatted; literals which are part of the larger frame will not have this property.

A version of the format method which it returns an array of objects which represent "parts" of the object, separating the formatted number into its constituent parts and separating it from other surrounding text. These objects have two properties: type a NumberFormat formatToParts type, and value, which is the String which is the component of the output. If a "part" came from NumberFormat, it will have a unit property which indicates the unit being formatted; literals which are part of the larger frame will not have this property.

Value Params
unit
  • Unit to use in the relative time internationalized message. Possible values are: "year", "quarter", "month", "week", "day", "hour", "minute", "second". Plural forms are also permitted.
value
  • Numeric value to use in the internationalized relative time message
Throws
`RangeError`

if unit was given something other than unit possible values

Provides access to the locale and options computed during initialization of this Intl.RelativeTimeFormat object.

Provides access to the locale and options computed during initialization of this Intl.RelativeTimeFormat object.

Inherited methods

def hasOwnProperty(v: String): Boolean
Inherited from
Object
def isPrototypeOf(v: Object): Boolean
Inherited from
Object
def propertyIsEnumerable(v: String): Boolean
Inherited from
Object
def toLocaleString(): String
Inherited from
Object
def valueOf(): Any
Inherited from
Object