mirror of
https://github.com/elyby/accounts-frontend.git
synced 2024-12-05 04:59:26 +05:30
20 lines
546 B
JavaScript
20 lines
546 B
JavaScript
|
// @flow
|
||
|
import React from 'react';
|
||
|
import { FormattedRelativeTime } from 'react-intl';
|
||
|
import { selectUnit } from '@formatjs/intl-utils';
|
||
|
|
||
|
function RelativeTime({timestamp}: {timestamp: number}) {
|
||
|
const {unit, value}: {unit: any, value: number} = selectUnit(timestamp);
|
||
|
|
||
|
return (
|
||
|
<FormattedRelativeTime
|
||
|
value={value}
|
||
|
unit={unit}
|
||
|
numeric="auto"
|
||
|
updateIntervalInSeconds={['seconds', 'minute', 'hour'].includes(unit) ? 1 : undefined}
|
||
|
/>
|
||
|
);
|
||
|
}
|
||
|
|
||
|
export default RelativeTime;
|