-
Notifications
You must be signed in to change notification settings - Fork 516
format relative time #321
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
base: master
Are you sure you want to change the base?
format relative time #321
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,15 @@ | ||||||||
| ```javascript | ||||||||
| const rtf = (value, unit) => new Intl.RelativeTimeFormat('en').format(value, unit); | ||||||||
|
|
||||||||
| /* | ||||||||
| value - Numeric value to use in the internationalized relative time message. | ||||||||
| unit - Unit to use in the relative time internationalized message. | ||||||||
| Possible values are: "year", "quarter", "month", "week", "day", "hour", "minute", "second". | ||||||||
| Plural forms are also permitted. | ||||||||
| */ | ||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It would be great if the local could be passed as an optional parameter. |
||||||||
|
|
||||||||
| // Example | ||||||||
| rtf(5, 'day'); // in 5 days | ||||||||
| rtf(-3, 'day'); // 3 days ago | ||||||||
| rtf(2, 'minutes'); // in 2 min | ||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
| ``` | ||||||||
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.