-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix/AELF_24674424: In all transactions list, the content of age is di…
…fferent from explorer.
- Loading branch information
1 parent
173f0d7
commit 0a02ffb
Showing
2 changed files
with
21 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,25 @@ | ||
|
||
import { differenceInMilliseconds } from "date-fns"; | ||
import {ChainStateEnum} from "@/state"; | ||
|
||
export const CHAIN_OPTIONS: Record<ChainStateEnum, string> = { | ||
[ChainStateEnum.AELF]: 'MainChain '.concat(ChainStateEnum.AELF), | ||
[ChainStateEnum.tDVV]: 'SideChain '.concat(ChainStateEnum.tDVV), | ||
[ChainStateEnum.tDVW]: 'SideChain '.concat(ChainStateEnum.tDVW), | ||
} | ||
|
||
export const getLastTwoUnits = (date) => { | ||
const now = new Date(); | ||
const distance = differenceInMilliseconds(now, date); | ||
|
||
const days = Math.floor(distance / (1000 * 60 * 60 * 24)); | ||
const hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60)); | ||
const minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60)); | ||
|
||
if (days > 0) { | ||
return `${days} day${days > 1 ? 's' : ''} ${hours} hr${hours > 1 ? 's' : ''} ago`; | ||
} else if (hours > 0) { | ||
return `${hours} hr${hours > 1 ? 's' : ''} ${minutes} min${minutes > 1 ? 's' : ''} ago`; | ||
} else { | ||
return `${minutes} min${minutes > 1 ? 's' : ''} ago`; | ||
} | ||
} |