@injectivelabs/utils
Advanced tools
Comparing version 1.0.15 to 1.0.16
import { BigNumberInBase, BigNumber } from './classes'; | ||
export declare const SECONDS_IN_A_DAY: BigNumber; | ||
export declare const convertTimestampToMilliseconds: (timestamp: number) => number; | ||
export declare const convertTimestampToMilliseconds: (timestamp: number | string) => number; | ||
export declare const getUTCDateFromTimestamp: (timestamp: number) => string; | ||
@@ -5,0 +5,0 @@ export declare const tomorrow: () => BigNumber; |
@@ -7,9 +7,13 @@ "use strict"; | ||
const convertTimestampToMilliseconds = (timestamp) => { | ||
const timestampInBigNumber = new classes_1.BigNumberInBase(timestamp); | ||
if (timestamp.toString().length > 13) { | ||
return parseInt(timestamp.toString().slice(0, 13), 10); | ||
return timestampInBigNumber | ||
.precision(13, classes_1.BigNumber.ROUND_HALF_UP) | ||
.toNumber(); | ||
} | ||
if (timestamp.toString().length < 13) { | ||
return parseInt(`${timestamp}${'0'.repeat(13 - timestamp.toString().length)}`, 10); | ||
const trailingZeros = 13 - timestamp.toString().length; | ||
return timestampInBigNumber.times(Math.pow(10, trailingZeros)).toNumber(); | ||
} | ||
return timestamp; | ||
return timestampInBigNumber.toNumber(); | ||
}; | ||
@@ -16,0 +20,0 @@ exports.convertTimestampToMilliseconds = convertTimestampToMilliseconds; |
{ | ||
"name": "@injectivelabs/utils", | ||
"description": "List of utils and helper functions that can be reused throughout Injective's projects.", | ||
"version": "1.0.15", | ||
"version": "1.0.16", | ||
"author": { | ||
@@ -43,3 +43,3 @@ "name": "Bojan Angjelkoski", | ||
}, | ||
"gitHead": "554b7c6e44ef563b46b82491cb4757575c51e6c9" | ||
"gitHead": "81402967d829bf7d279dd84096899530b541b503" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
80987
1071
20
0
63