intl-relativeformat
Version:
Formats JavaScript dates to relative time strings.
30 lines (29 loc) • 1.04 kB
TypeScript
import { default as IntlRelativeTimeFormat } from '@formatjs/intl-relativetimeformat';
import { SUPPORTED_FIELD, STYLE, LocaleData } from './types';
declare global {
namespace Intl {
var RelativeTimeFormat: typeof IntlRelativeTimeFormat;
}
}
export interface IntlRelativeFormatOptions {
style?: STYLE;
units?: SUPPORTED_FIELD;
}
interface IntlRelativeFormat {
new (locales?: string | string[], opts?: IntlRelativeFormatOptions): IntlRelativeFormat;
(locales?: string | string[], opts?: IntlRelativeFormatOptions): IntlRelativeFormat;
thresholds: Record<string, number>;
defaultLocale: string;
__localeData__: Record<string, LocaleData>;
__addLocaleData(...data: LocaleData[]): void;
format(date: ConstructorParameters<typeof Date>[0], opts?: {
now?: Date | number | null;
}): string;
resolvedOptions(): {
locale: string;
style: STYLE;
units?: SUPPORTED_FIELD;
};
}
declare const RelativeFormat: IntlRelativeFormat;
export default RelativeFormat;