2019-11-11 14:10:05 +05:30
|
|
|
import React from 'react';
|
|
|
|
import { FormattedRelativeTime } from 'react-intl';
|
|
|
|
import { selectUnit } from '@formatjs/intl-utils';
|
|
|
|
|
2019-11-27 14:33:32 +05:30
|
|
|
function RelativeTime({ timestamp }: { timestamp: number }) {
|
2019-12-07 16:58:52 +05:30
|
|
|
const { unit, value }: { unit: any; value: number } = selectUnit(timestamp);
|
2019-11-11 14:10:05 +05:30
|
|
|
|
2019-11-27 14:33:32 +05:30
|
|
|
return (
|
|
|
|
<FormattedRelativeTime
|
|
|
|
value={value}
|
|
|
|
unit={unit}
|
|
|
|
numeric="auto"
|
|
|
|
updateIntervalInSeconds={
|
|
|
|
['seconds', 'minute', 'hour'].includes(unit) ? 1 : undefined
|
|
|
|
}
|
|
|
|
/>
|
|
|
|
);
|
2019-11-11 14:10:05 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
export default RelativeTime;
|