@formatjs/intl-relativetimeformat

  • Version 12.3.15
  • Published
  • 12.4 MB
  • 1 dependency
  • MIT license

Install

npm i @formatjs/intl-relativetimeformat
yarn add @formatjs/intl-relativetimeformat
pnpm add @formatjs/intl-relativetimeformat

Overview

Formats JavaScript dates to relative time strings.

Index

Classes

class RelativeTimeFormat

class RelativeTimeFormat {}

    constructor

    constructor(
    locales?: string | string[],
    options?: Intl.RelativeTimeFormatOptions
    );

      property localeData

      static localeData: Record<string, LocaleFieldsData>;

        property polyfilled

        static polyfilled: boolean;

          method format

          format: (value: number, unit: Intl.RelativeTimeFormatUnit) => string;

            method formatToParts

            formatToParts: (
            value: number,
            unit: Intl.RelativeTimeFormatUnit
            ) => Intl.RelativeTimeFormatPart[];

              method resolvedOptions

              resolvedOptions: () => Intl.ResolvedRelativeTimeFormatOptions;

                method supportedLocalesOf

                static supportedLocalesOf: (
                locales: string | string[],
                options?: Pick<Intl.RelativeTimeFormatOptions, 'localeMatcher'>
                ) => string[];

                  Interfaces

                  interface FieldData

                  interface FieldData {}

                    property "-1"

                    '-1'?: string;

                      property "-2"

                      '-2'?: string;

                        property "-3"

                        '-3'?: string;

                          property "0"

                          '0'?: string;

                            property "1"

                            '1'?: string;

                              property "2"

                              '2'?: string;

                                property "3"

                                '3'?: string;

                                  property future

                                  future: RelativeTimeData;

                                    property past

                                    past: RelativeTimeData;

                                      interface LocaleData

                                      interface LocaleData<T> {}

                                        property data

                                        data: T;

                                          property locale

                                          locale: Locale;

                                            Type Aliases

                                            type LDMLPluralRule

                                            type LDMLPluralRule = 'zero' | 'one' | 'two' | 'few' | 'many' | 'other';

                                              type Locale

                                              type Locale = string;

                                                type LocaleFieldsData

                                                type LocaleFieldsData = { [f in RelativeTimeField]?: FieldData } & {
                                                nu?: Array<string | null>;
                                                };

                                                  type RelativeTimeData

                                                  type RelativeTimeData = { [u in LDMLPluralRule]?: string };

                                                    type RelativeTimeField

                                                    type RelativeTimeField =
                                                    | 'second'
                                                    | 'second-short'
                                                    | 'second-narrow'
                                                    | 'minute'
                                                    | 'minute-short'
                                                    | 'minute-narrow'
                                                    | 'hour'
                                                    | 'hour-short'
                                                    | 'hour-narrow'
                                                    | 'day'
                                                    | 'day-short'
                                                    | 'day-narrow'
                                                    | 'week'
                                                    | 'week-short'
                                                    | 'week-narrow'
                                                    | 'month'
                                                    | 'month-short'
                                                    | 'month-narrow'
                                                    | 'quarter'
                                                    | 'quarter-short'
                                                    | 'quarter-narrow'
                                                    | 'year'
                                                    | 'year-short'
                                                    | 'year-narrow';

                                                      type RelativeTimeLocaleData

                                                      type RelativeTimeLocaleData = LocaleData<LocaleFieldsData>;

                                                        Package Files (1)

                                                        Dependencies (1)

                                                        Dev Dependencies (0)

                                                        No dev dependencies.

                                                        Peer Dependencies (0)

                                                        No peer dependencies.

                                                        Badge

                                                        To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

                                                        You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/@formatjs/intl-relativetimeformat.

                                                        • Markdown
                                                          [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/@formatjs/intl-relativetimeformat)
                                                        • HTML
                                                          <a href="https://www.jsdocs.io/package/@formatjs/intl-relativetimeformat"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>