UNPKG

react-intlayer

Version:

Easily internationalize i18n your React applications with type-safe multilingual content management.

29 lines (27 loc) 1.06 kB
import * as _intlayer_types14 from "@intlayer/types"; //#region src/client/format/useRelativeTime.d.ts /** * Client-side React hook for accessing a localized relative time formatter. * * This hook: * - Reads the current locale from {@link useLocaleBase}. * - Creates a new relative time formatter with {@link createRelativeTime}. * - Returns a function that can format time differences into localized strings. * * Example: * ```tsx * const relativeTime = useRelativeTime(); * const formatted = relativeTime(new Date("2024-08-01"), new Date()); * // e.g., "2 weeks ago" * ``` * * @returns {ReturnType<typeof createRelativeTime>} A relative time formatting function * bound to the current client locale. */ declare const useRelativeTime: () => (from: string | number | Date, to?: string | number | Date, options?: Intl.RelativeTimeFormatOptions & { locale?: _intlayer_types14.LocalesValues; unit?: Intl.RelativeTimeFormatUnit; }) => string; //#endregion export { useRelativeTime }; //# sourceMappingURL=useRelativeTime.d.ts.map