Update packages/core/helper-plugin/src/components/RelativeTime/index.js

Co-authored-by: Josh <37798644+joshuaellis@users.noreply.github.com>
This commit is contained in:
Marc 2023-06-28 10:04:38 +02:00 committed by GitHub
parent 4ad16d5dcd
commit e1b51c84c5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -8,12 +8,15 @@ import { useIntl } from 'react-intl';
* Displays the relative time between a given timestamp and the current time.
* You can display a custom message for given time intervals by passing an array of custom intervals.
*
* @example <caption>Display "last hour" if the timestamp is less than an hour ago</caption>
* @example
* ```jsx
* <caption>Display "last hour" if the timestamp is less than an hour ago</caption>
* <RelativeTime
* timestamp={new Date('2021-01-01')}
* customIntervals={[
* { unit: 'hours', threshold: 1, text: 'last hour' },
* ]}
* ```
*/
const RelativeTime = ({ timestamp, customIntervals }) => {
const { formatRelativeTime, formatDate, formatTime } = useIntl();