-
-
Notifications
You must be signed in to change notification settings - Fork 253
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Add the custom unit option of relativeTime
#566
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
@ktmouk is attempting to deploy a commit to the next-intl Team on Vercel. A member of the Team first needs to authorize it. |
relativeTime
relativeTime
relativeTime
relativeTime
relativeTime
relativeTime
const UNIT_SECONDS = { | ||
second: SECOND, | ||
seconds: SECOND, | ||
minute: MINUTE, | ||
minutes: MINUTE, | ||
hour: HOUR, | ||
hours: HOUR, | ||
day: DAY, | ||
days: DAY, | ||
week: WEEK, | ||
weeks: WEEK, | ||
month: MONTH, | ||
months: MONTH, | ||
quarter: QUARTER, | ||
quarters: QUARTER, | ||
year: YEAR, | ||
years: YEAR | ||
} as const; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added quarter
and plural forms to make it match RelativeTimeFormatUnit type.
years: YEAR | ||
} as const; | ||
|
||
function resolveRelativeTimeUnit(seconds: number) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't add quarter
here because I believe we don't want to use the quarter
unit in most cases.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What a fantastic PR, thank you so much for this great contribution! 👏👏
I only added a minor commit from a local experiment where I wanted to check if the map you've introduced covers all relative time units.
This PR adds the
relativeTime
options to support custom units and updates the documentation accordingly.Close: #565