Skip to content

Support Intl.RelativeTimeFormat for relativeTime formatting #1056

@kvnxiao

Description

@kvnxiao

Is your feature request related to a problem? Please describe.

Currently, the formatter for Formatting date and time ranges does not support additional configuration other than specifying the exact unit to display the output in.

The relative time formatting should support all the options from Intl.RelativeTimeFormat and not just RelativeTimeFormatUnit

Describe the solution you'd like

Instead of:

type RelativeTimeFormatOptions = {
    now?: number | Date;
    unit?: Intl.RelativeTimeFormatUnit;
};
export default RelativeTimeFormatOptions;

The RelativeTimeFormatOptions type should also accept the options from the Intl.RelativeTimeFormat constructor:

  • numberingSystem
  • style
  • numeric

Describe alternatives you've considered

The only alternative would be to use the native Intl API directly, but this should be integrated into the formatter in next-intl IMO

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions