Skip to content

Commit

Permalink
fix: minor
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasRalee committed Jan 29, 2024
1 parent ba6e1cd commit b7121ee
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions layer/utils/formatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit b7121ee

Please sign in to comment.