2021-01-14 00:43:35 +01:00
|
|
|
import React from 'react'
|
|
|
|
import { useTranslation } from 'react-i18next'
|
|
|
|
import { Text } from 'react-native'
|
|
|
|
import TimeAgo from 'react-timeago'
|
|
|
|
// @ts-ignore
|
|
|
|
import buildFormatter from 'react-timeago/lib/formatters/buildFormatter'
|
|
|
|
|
|
|
|
export interface Props {
|
2021-02-07 00:39:11 +01:00
|
|
|
date: string | number
|
2021-01-14 00:43:35 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
const RelativeTime: React.FC<Props> = ({ date }) => {
|
2021-01-19 01:13:45 +01:00
|
|
|
const { t } = useTranslation('componentRelativeTime')
|
2021-01-14 00:43:35 +01:00
|
|
|
|
2021-01-17 22:37:05 +01:00
|
|
|
return (
|
|
|
|
<TimeAgo
|
|
|
|
date={date}
|
|
|
|
component={Text}
|
|
|
|
formatter={buildFormatter(t('strings', { returnObjects: true }))}
|
|
|
|
/>
|
|
|
|
)
|
2021-01-14 00:43:35 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
export default RelativeTime
|