From b7121ee316c62c25aec01e43c40a45a16669f8b8 Mon Sep 17 00:00:00 2001 From: thomasRalee Date: Tue, 30 Jan 2024 05:10:39 +0800 Subject: [PATCH] fix: minor --- layer/utils/formatter.ts | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/layer/utils/formatter.ts b/layer/utils/formatter.ts index 5bb6a059..64d0ede2 100644 --- a/layer/utils/formatter.ts +++ b/layer/utils/formatter.ts @@ -21,9 +21,15 @@ export const sharedConvertTimestampToMilliseconds = ( const timestampInBigNumber = new BigNumberInBase(timestamp) if (timestamp.toString().length > 13) { - return timestampInBigNumber - .precision(13, BigNumber.ROUND_HALF_UP) - .toNumber() + const formatNumberBy = new BigNumberInBase(10).pow( + timestamp.toString().length - 13 + ) + + const formattedValue = timestampInBigNumber + .dividedBy(formatNumberBy) + .toFixed(0, BigNumber.ROUND_HALF_UP) + + return new BigNumberInBase(formattedValue).toNumber() } if (timestamp.toString().length < 13) {