Commit fc0ee3bc authored by Igor Stuev's avatar Igor Stuev Committed by GitHub

Merge pull request #2168 from blockscout/time-ago-noves-fix

fix time ago
parents 9c2e9907 341756f6
......@@ -19,7 +19,7 @@ function getUnits(diff: number) {
return [ DAY, 2 * DAY ];
}
function getUpdateParams(ts: string) {
function getUpdateParams(ts: string | number) {
const timeDiff = Date.now() - new Date(ts).getTime();
const [ unit, higherUnit ] = getUnits(timeDiff);
......@@ -41,7 +41,7 @@ function getUpdateParams(ts: string) {
};
}
export default function useTimeAgoIncrement(ts: string | null, isEnabled?: boolean) {
export default function useTimeAgoIncrement(ts: string | number | null, isEnabled?: boolean) {
const [ value, setValue ] = React.useState(ts ? dayjs(ts).fromNow() : null);
React.useEffect(() => {
......
......@@ -41,7 +41,7 @@ const AddressAccountHistoryListItem = (props: Props) => {
</Text>
</Flex>
<TimeAgoWithTooltip
timestamp={ (props.tx.rawTransactionData.timestamp * 1000).toString() }
timestamp={ props.tx.rawTransactionData.timestamp * 1000 }
color="text_secondary"
borderRadius="sm"
fontWeight={ 500 }
......
......@@ -26,7 +26,7 @@ const AddressAccountHistoryTableItem = (props: Props) => {
<Tr>
<Td px={ 3 } py="18px" fontSize="sm" >
<TimeAgoWithTooltip
timestamp={ (props.tx.rawTransactionData.timestamp * 1000).toString() }
timestamp={ props.tx.rawTransactionData.timestamp * 1000 }
isLoading={ props.isPlaceholderData }
color="text_secondary"
borderRadius="sm"
......
......@@ -5,7 +5,7 @@ import dayjs from 'lib/date/dayjs';
import useTimeAgoIncrement from 'lib/hooks/useTimeAgoIncrement';
type Props = {
timestamp?: string | null;
timestamp?: string | number | null;
fallbackText?: string;
isLoading?: boolean;
enableIncrement?: boolean;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment